Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I execute a command contained in a string?

Status
Not open for further replies.

mpruett

Programmer
Jul 22, 2005
13
0
0
US
I'm trying to execute a command I've strung together into a string;

I have something like this:


declare @Name varchar(255)

set @name = 'sp_rename ''test_table'',''test_table_2'''


I want to execute the sp_rename statement held in @name. How do I do that?

 
declare @Name varchar(255)

set @name = 'sp_rename ''test_table'',''test_table_2'''

[!]Exec (@Name)[/!]

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top