|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Calling TSQL Script from within TSQL ScriptHi,
Is it possible to have a script (e.g main.sql) that calls other sql scripts ? In Oracle you can use "@<path><filename>.sql to call it but I cannot find a way to do it in SQL Server. What I want to be able to do is run other scripts from my main script and be able to pass parameters to the sql files that I am calling. e.g @<path><filename> <param1> <param2> ....etc Any ideas :) You can use other mechanisms for the same. One such implementation is:
declare @r int, @file varchar(30) select @r=10, @file='c:\test.out' declare @sql varchar(1000) select @sql = 'osql -E -Ssrv1\dev -dNorthwind -Q"set rowcount '+cast(@r as varchar)+'; select orderid, shipcountry from orders; set rowcount 0;" -o'+@file exec master..xp_cmdshell @sql, no_output -- Show quoteHTH, Vinod Kumar MCSE, DBA, MCAD, MCSD http://www.extremeexperts.com Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp "Bluemonkey" <Bluemon***@discussions.microsoft.com> wrote in message news:75735740-350F-4F65-A558-925CEF699032@microsoft.com... > Hi, > > Is it possible to have a script (e.g main.sql) that calls other sql > scripts ? > > In Oracle you can use "@<path><filename>.sql to call it but I cannot find > a > way to do it in SQL Server. > > What I want to be able to do is run other scripts from my main script and > be > able to pass parameters to the sql files that I am calling. > > e.g @<path><filename> <param1> <param2> ....etc > > Any ideas :) Hi
If using osql or isql this may help: http://tinyurl.com/5299q John Show quote "Bluemonkey" wrote: > Hi, > > Is it possible to have a script (e.g main.sql) that calls other sql scripts ? > > In Oracle you can use "@<path><filename>.sql to call it but I cannot find a > way to do it in SQL Server. > > What I want to be able to do is run other scripts from my main script and be > able to pass parameters to the sql files that I am calling. > > e.g @<path><filename> <param1> <param2> ....etc > > Any ideas :) |
|||||||||||||||||||||||