Wednesday, March 7, 2012

Execute sql script in the job

Hi!
I want to run a sql script in the job using T-SQL against a user
database. I tried to copy and paste the whole script in the T-SQL window
of the job but bc of length of the script (it is too long), it truncated
half of the script. How do I do that? Can we call this script using
xp_cmdshell and execute it? Is that possible? Any ideas?
The other option is to run it in the Query Analyzer which is a manual
effort and I do not want to do it bc this process is going to be ongoing
process and it is better if we make it automated.
Thanks for your help!
*** Sent via Developersdex http://www.examnotes.net ***"Test Test" <farooqhs_2000@.yahoo.com> wrote in message
news:#6MfyY6XFHA.2688@.TK2MSFTNGP10.phx.gbl...
> Hi!
> I want to run a sql script in the job using T-SQL against a user
> database. I tried to copy and paste the whole script in the T-SQL window
> of the job but bc of length of the script (it is too long), it truncated
> half of the script. How do I do that? Can we call this script using
> xp_cmdshell and execute it? Is that possible? Any ideas?
> The other option is to run it in the Query Analyzer which is a manual
> effort and I do not want to do it bc this process is going to be ongoing
> process and it is better if we make it automated.
> Thanks for your help!
> *** Sent via Developersdex http://www.examnotes.net ***
Why not put the T-SQL code in to a stored procedure and then have the job
call the stored procedure.
Rick Sawtell
MCT, MCSD, MCDBA|||Thanks Rick but we do not want to create stored procs:
1) avoid creating objects.
2) these scripts will also apply against other dbs ..so again it would
be a manual effort to create procs first and then run it under a job.
Any other ideas?
*** Sent via Developersdex http://www.examnotes.net ***|||"Test Test" <farooqhs_2000@.yahoo.com> wrote in message
news:#M4q9L8XFHA.4000@.TK2MSFTNGP10.phx.gbl...
> Thanks Rick but we do not want to create stored procs:
> 1) avoid creating objects.
> 2) these scripts will also apply against other dbs ..so again it would
> be a manual effort to create procs first and then run it under a job.
> Any other ideas?
> *** Sent via Developersdex http://www.examnotes.net ***
Perhaps a DTS package then. You could call the package from a job.
Rick Sawtell
MCT, MCSD, MCDBA

No comments:

Post a Comment