Sunday, March 11, 2012

Calling a SQL script from T-SQL code

Hi !
I am using Win2K and Microsoft SQL Server 2000.
I have a text file of more than 10000 lines of T-SQL.
Depending on some condition to be determined in another SQL script at run
time,
I should like to have the T-SQL in that text file executed or not.
Can I have a SQL script executed from within another SQL script ?
Thanks for any helpful remarks.
PeterWhy can't you put the script into a proc and then execute the proc
conditionally?
I guess you could make a call to OSQL via xp_cmdshell if you must
execute a script file. I can't think of a good reason to do it that way
but I can think of plenty of good reasons why you *shouldn't* do it
that way!
David Portas
SQL Server MVP
--|||peshrad wrote:
> Hi !
> I am using Win2K and Microsoft SQL Server 2000.
> I have a text file of more than 10000 lines of T-SQL.
> Depending on some condition to be determined in another SQL script at run
> time,
> I should like to have the T-SQL in that text file executed or not.
> Can I have a SQL script executed from within another SQL script ?
> Thanks for any helpful remarks.
> Peter
>
you can create a job with first step to check condition and second to
run the script (if the condition is met)

No comments:

Post a Comment