Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQLCMD how to use drive and path in scripting variables Expand / Collapse
Author
Message
Posted Wednesday, January 30, 2008 11:53 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 9:43 AM
Points: 289, Visits: 333
OK. I have run out of ideas..

I am trying to place all the scripting variables in a file and have my sqlcmd like be populated at runtime witht he appropriate values. For example..

:Setvar DistributionServerDataFolderName "N'e:\Data'"

and then call...

:!!sqlcmd -E -S db51 -d master -o scriptout1.txt -v SVDistributionServerDataFolderName =$(DistributionServerDataFolderName) -i InstallDistribution.sql
:go
:exit

when it replaces the DistributionServerDataFolderName with N'e:\Data'
it interpets the colon as a command and produces the error...

Sqlcmd: ':\Data' ': Invalid argument. Enter '-?' for help.

i have tried delimiting this every which way possible, but no success.

what am i doing wrong? what can i change?

Please help!

thanks

Post #449592
Posted Friday, February 1, 2008 6:06 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, November 12, 2013 8:44 AM
Points: 1,073, Visits: 6,334
It looks like the SQLCMD -v option is expecting the variable to be quoted.
SQLCMD -v myVariable="myValue"

To get the the variable quoted add an additional set of double quotes:
:SETVAR myVariable """N'C:\temp'"""

:!!ECHO $(myVariable)

Post #450421
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse