June 11, 2014 at 4:29 pm
:setvar Instance SUBSTRING(@@SERVERNAME,7,3)
:setvar FolderPath "\\Here\there\where"
I have two sqlcmd variables that i need to concatenate and store the values in the third variable and use that variable in a query.
somthing like
:setvar FullName $(FolderPath)+$(FolderPath)
how can this be done, i tried a couple methods- don't seem to work- any idea?
June 15, 2014 at 4:16 am
peacesells (6/11/2014)
:setvar Instance SUBSTRING(@@SERVERNAME,7,3):setvar FolderPath "\\Here\there\where"
I have two sqlcmd variables that i need to concatenate and store the values in the third variable and use that variable in a query.
somthing like
:setvar FullName $(FolderPath)+$(FolderPath)
how can this be done, i tried a couple methods- don't seem to work- any idea?
No need to concatenate the sqlcmd scripting variables, just do the concatenation in the query.
:setvar PartOne 'first_'
:setvar PartTwo 'second'
go
select char(39) + $(PartOne) + $(PartTwo) + char(39) as full_path
go
Results
full_path
--------------
'first_second'
June 15, 2014 at 4:42 am
peacesells (6/11/2014)
how can this be done, i tried a couple methods- don't seem to work- any idea?
Forgot to answer the question:-D
It's not possible to programmatically set or concatenate the variables without writing to a file.
June 15, 2014 at 9:35 am
Based on what Eirikur posted above, why not build a stored procedure that does this work and execute the stored procedure from SQLCmd, instead?
Also, why are you using SQLCmd? What is it that you're actually trying to do overall? I ask because there may be better methods.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy