September 30, 2013 at 3:21 am
Hi,
I a mtrying to create update staments including data for the table in this way but I am getting error
Incorrect syntax near '+'.
Can anyone tell me whats wrongs in this script?
SELECT 'UPDATE table_1
SET labeltext ='+ T.labeltext
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey
'AND FileID =' + T.FileID
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 30, 2013 at 3:25 am
SELECT 'UPDATE table_1
SET labeltext ='+ T.labeltext +
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey +
'AND FileID =' + T.FileID
Try this one. You are forgetting one "+" on the right side of LabelKey and labeltext.
September 30, 2013 at 3:30 am
sqlnaive (9/30/2013)
SELECT 'UPDATE table_1
SET labeltext ='+ T.labeltext +
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey +
'AND FileID =' + T.FileID
Try this one. You are forgetting one "+" on the right side of LabelKey and labeltext.
still getting error:
The multi-part identifier "T.labeltext" could not be bound.
Msg 4104, Level 16, State 1, Line 4
The multi-part identifier "T.LabelKey" could not be bound.
Msg 4104, Level 16, State 1, Line 5
The multi-part identifier "T.FileID" could not be bound.
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 30, 2013 at 3:44 am
can you put your code in more details?
What are these T.labeltext , T.LabelKey, T.FileID.
error message is clear
September 30, 2013 at 3:48 am
SrcName (9/30/2013)
can you put your code in more details?What are these T.labeltext , T.LabelKey, T.FileID.
error message is clear
SELECT 'UPDATE table_1 T
SET labeltext ='+ T.labeltext
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey
'AND FileID =' + T.FileID
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 30, 2013 at 4:10 am
kapil_kk (9/30/2013)
SrcName (9/30/2013)
can you put your code in more details?What are these T.labeltext , T.LabelKey, T.FileID.
error message is clear
SELECT 'UPDATE table_1 T
SET labeltext ='+ T.labeltext
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey
'AND FileID =' + T.FileID
SELECT 'UPDATE table_1 T
SET labeltext ='+ T.labeltext +
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey +
'AND FileID =' + T.FileID
FROM You_Need_A_Source AS T
September 30, 2013 at 4:26 am
Sean Pearce (9/30/2013)
kapil_kk (9/30/2013)
SrcName (9/30/2013)
can you put your code in more details?What are these T.labeltext , T.LabelKey, T.FileID.
error message is clear
SELECT 'UPDATE table_1 T
SET labeltext ='+ T.labeltext
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey
'AND FileID =' + T.FileID
SELECT 'UPDATE table_1 T
SET labeltext ='+ T.labeltext +
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey +
'AND FileID =' + T.FileID
FROM You_Need_A_Source AS T
Hi,
Try with this
SELECT 'UPDATE table_1 T
SET labeltext ='''+ T.labeltext +
''' WHERE LanguageID = 10
AND LabelKey ='''+ T.LabelKey +
''' AND FileID =''' + T.FileID + ''''
FROM You_Need_A_Source AS T
September 30, 2013 at 8:21 am
parulprabu (9/30/2013)
Sean Pearce (9/30/2013)
kapil_kk (9/30/2013)
SrcName (9/30/2013)
can you put your code in more details?What are these T.labeltext , T.LabelKey, T.FileID.
error message is clear
SELECT 'UPDATE table_1 T
SET labeltext ='+ T.labeltext
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey
'AND FileID =' + T.FileID
SELECT 'UPDATE table_1 T
SET labeltext ='+ T.labeltext +
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey +
'AND FileID =' + T.FileID
FROM You_Need_A_Source AS T
Hi,
Try with this
SELECT 'UPDATE table_1 T
SET labeltext ='''+ T.labeltext +
''' WHERE LanguageID = 10
AND LabelKey ='''+ T.LabelKey +
''' AND FileID =''' + T.FileID + ''''
FROM You_Need_A_Source AS T
This assumes that T.LabelKey & T.FileID are character fields. If not then they will have to be CAST to VARCHAR.
Kurt
Kurt W. Zimmerman
SR DBA
Lefrak Organization
New York, NY
http://www.linkedin.com/in/kurtwzimmerman
October 1, 2013 at 1:11 am
Thanks a lot guys for your help....
I have created the script now :-D:-P
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
October 8, 2013 at 5:30 am
SELECT 'UPDATE table_1
SET labeltext ='+ T.labeltext +
from tableName T(Need Here)
'WHERE LanguageID = 10
AND LabelKey ='+ T.LabelKey +
'AND FileID =' + T.FileID
October 8, 2013 at 6:24 pm
The elephant on the carpet here of course is that the next statement in line is going to be:
EXEC (@UpdateScript)
And that is going to be highly prone to SQL injection. Using sp_executesql with parameters passed in is going to be much safer.
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
October 8, 2013 at 8:33 pm
dwain.c (10/8/2013)
The elephant on the carpet here of course is that the next statement in line is going to be:
EXEC (@UpdateScript)
And that is going to be highly prone to SQL injection. Using sp_executesql with parameters passed in is going to be much safer.
+1 to that. Hello "Little Bobby Tables"! 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply