SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Variable String + Variable


Variable String + Variable

Author
Message
samtwilliams
samtwilliams
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 12
I am modifying a script that creates Jobs, is it possible to achieving the following;

@command=N'Some Command' + @ANOTHER_VARIABLE


I need to tag the contents of another variable to then end of one being set.

Can anyone explain how i could achieve this, my real life example is

@command=N'Exec dbo.pReport_Update_Unit ''E:\MyData\Target\CSV''',


I need the Path including single quotes to be passed in by a variable set further up the script, i expected my script to work or look something like below;
e.g.

DECLARE @variable varchar(100)
SET @variable = ''E:\MyData\Target\CSV''
@command=N'Exec dbo.pReport_Update_Unit '+@variable,

samtwilliams
samtwilliams
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 12
Can anyoen help with this.

Thanks
ChrisM@Work
ChrisM@Work
SSC Guru
SSC Guru (72K reputation)SSC Guru (72K reputation)SSC Guru (72K reputation)SSC Guru (72K reputation)SSC Guru (72K reputation)SSC Guru (72K reputation)SSC Guru (72K reputation)SSC Guru (72K reputation)

Group: General Forum Members
Points: 72738 Visits: 20308
samtwilliams (9/19/2012)
Can anyoen help with this.

Thanks


DECLARE @variable varchar(100), @command VARCHAR(500)
SET @variable = 'E:\MyData\Target\CSV'
SET @command = N'Exec dbo.pReport_Update_Unit ''' + @variable + ''''
SELECT @command



“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search