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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQLCMD -x flag propagated through included scripts

Author  Topic 

CountSpatula
Starting Member

1 Post

Posted - 2011-01-24 : 12:25:31
Hi everyone,

Just found this forum and I'm hoping someone here can help me as I've been wrestling with this SQLCMD issue for a while and can't find any information on it.

I have a script that, quite simply, has a couple of other scripts included with the :r parameter and wraps them in a transaction, like so:
BEGIN TRANSACTION
:r file1
:r file2
<error handling: COMMIT or ROLLBACK TRANSACTION>


One of my files inserts a string that is something like 'abc$(xyz)'.
This fails if I run SQLCMD because it complains that xyz is not a valid script variable. Fair enough, so I use the -x flag and then it works perfectly fine.
Except, if I call the main script it always fails, with or without the -x flag. So I'm guessing the issue is that the -x flag only applies to the script being called, not the included ones.

Is there any way around this? Any help is appreciated.

Thanks very much,
A
   

- Advertisement -