Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL script as scheduled task

Status
Not open for further replies.

denniswb

Programmer
Jun 8, 2000
5
CA
I have a lengthy SQL script that creates several tables in several databases and culminates in a single table for use in a Crystal report. It runs nicely in isql. Is there a way that I can run this script as a scheduled task? It is way larger than the 255 character limit for TSQL in Scheduled Tasks.

Thanks

Dennis
 
I thought of that but I believe that would require that I break it up into a stored procedure for each database as USE cannot be used in a stored procedure. Then I need to merge data from 4 databases into 1 after processing in each.

Dennis
 
Schedule a task as a type CmdExec and use this as the command, populated your required data like password and database name:

c:\mssql\binn\isql /U sa /P PASSWORD /d DATABASENAME /i c:\mssql\binn\yourfile.sql /o c:\mssql\binn\yourfile.out

You can also use a batch file and have the batch file called by the NT schedule service.
 
I used your first method on a test script (I had been trying it this way but didn't get it quite right) and it worked. Thanks a lot for your help.

Dennis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top