Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 concatenate a string inside exec()

Author  Topic 

whatamouth
Starting Member

16 Posts

Posted - 2011-12-29 : 10:07:00
Hi, can anyone help me out with this one.
I'm kind of stuck

I need to use an sp_rename inside an exec() clause.

declare @test_char vharchar(4)
SET @test_char varchar = 'ABC123'
exec ('exec sp_rename "table", "table"+@test_char')


Executing the script above would return this message >
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '+'.

Wondering if how would I concatenate the new table name and the variable @test_char

Thanks in Advance!

Neil Matias
neilmatias@yahoo.com

X002548
Not Just a Number

15586 Posts

Posted - 2011-12-29 : 11:06:17
set your sting to a variable

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -