Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
swingnchad
Starting Member
4 Posts |
Posted - 2011-02-17 : 13:13:40
|
I need to execute a .sql script from a Sql Server Agent job, but in the same running session/connection as the existing one. The job has 2 steps:The first one runs an sql command and creates a temp table (can be local or global). The second step uses the CmdExec command to run sqlcmd to execute the .sql script, but that would create a new sql connection which wouldn't allow the script to access the global temp table created in the previous step. I'd like to somehow import the .sql script into my current session so it can access the global temp table that was created in the first step.Note: the .sql script changes dynamically so I can't simply copy the contents of it into a 3rd step. |
|
KlausEngel
Yak Posting Veteran
85 Posts |
Posted - 2011-02-17 : 17:56:32
|
If you run three subsequent queries, couldn't you wrap all your queries into a stored procedure and than call the execution of the sp from the Agent? |
 |
|
|
|
|