Is it possible to have this in an UPDATE statement?<br><br>UPDATE table SET @str1+@str2 = '001'<br><br>I got the result of "1 row affected" <br>But when I try to select that column, it wasn't updated.<br>The result remains NULL.<br><br>Thank you.
I should've taken more notice of your subject.<br><br>I don't have access to SQL server to tell you what you're doing wrong but I can offer this:<br><br>Try<br><br>DECLARE @Command VARCHAR(100)<br>SET @Command = 'UPDATE table SET ' + @str1 + @str2 + ' = "001"'<br>EXEC (@Command)
Invicta.<br><br>I quote an example.<br><br>declare @str1 = 'First'<br>declare @str2 = 'Name'<br>declare @command varchar(100)<br><br>I need it to update the column name
I'm still unsure of what you're trying to achieve.<br><br>The final comment in your last message seems to imply that you're trying to change the name of a column in a table. If this is the case then I'm unaware of any way of doing this other than rebuilding the table.<br><br>If you're trying to catenate two variables to make up the name of a column for subsequent update then my previous example gives the code to do that.<br><br><br>Maybe if you show me more code I'll get a better grasp?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.