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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Statement from text file

Status
Not open for further replies.

PLV

Programmer
Apr 29, 2001
15
0
0
US
Is there a way to load a sql statement written in a text file with the object "execute SQL task"?



 
Yes by using ISQL or OSQL.
Example, for starting a job in sql2000.

isql /S your_server /E /d msdb /n /Q "EXEC msdb.dbo.sp_start_job 'Your Task Here'"

-- in 6.5 use, sp_runtask


Here's an example on how you run script written in text file.

isql /S your_server /E -i "your_sql_script.sql.sql" -n -w2000
Andel
andel@barroga.net
 
thx alot!

but is there a way of like automatically load the file into the SQL Statement.

I'm presently using the "Dynamic parameter object" to change things and I'd like to do the same to specify the script file to execute.

The trouble with your solution is that my server and connection change so it's hard to make a command line like the one you told me.

Isn't there a way to import the file into a variable and put the variable into the Dynamic property of the SQL statement or something like that?

;-)

Thx alot
 
You don't have to type these all the time, you can put this in a .BAT file then make the server name as a parameter if server name keeps changing. You should also be able to make your script file a parameter in the batch file.

I'm not sure if this is what you want.


Andel
andel@barroga.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top