Quantcast
Channel: Getting started with SQL Server forum
Viewing all articles
Browse latest Browse all 9243

Using the ":r" sqlcmd command

$
0
0

hi, 

use the :r command in SQLCMD script to include anotherscript  into the calling script. Just like this,

http://www.mssqltips.com/sqlservertip/1543/using-sqlcmd-to-execute-multiple-sql-server-scripts/

The problem is, I found that the :r command works fine until I move it into a IF or BEGIN TRY/END TRY statement. I.e., the :r command won't work if I enclose it within other statements. 

Is it a known issue, or I've neglected something? 

http://msdn.microsoft.com/en-us/library/ms162773.aspx say, 

"If the file contains Transact-SQL statements that are not followed by GO, you must enter GO on the line that follows :r."

but I've done that. 

Please help.

Thanks



Viewing all articles
Browse latest Browse all 9243


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>