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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 SQL COMMAND LINE - VARIABLE ALREADY DECLARED

Author  Topic 

mruprai
Starting Member

12 Posts

Posted - 2014-08-21 : 07:26:39
Hi,

im using SQL cmd line to run multiple scripts at once.

one issue I get is that I get the error 'variables are already declared.

the script I run is as follows

:r $(InstallPath)$(PrepScriptDIR)ImportScript_EDIT.sql

:r $(InstallPath)$(PrepScriptDIR)ImportTestsUpdate.sql

is there anyway to kind of put something in between these too scripts to clear all variables?

kind regards

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2014-08-21 : 08:28:51
There is no way to "undeclare".
:r tells me you are using the possibility to call scripts in scripts.
So the clean way could be to declare the variables only once in an early script.

Another way, don't know if it works, but you can try: insert a new scriptfile between them with the one and only statement GO to clear all...


Too old to Rock'n'Roll too young to die.
Go to Top of Page
   

- Advertisement -