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.
| Author |
Topic |
|
clerus
Starting Member
8 Posts |
Posted - 2008-12-03 : 05:44:56
|
Hello there!! Maybe someone could give a solution for this. Im trying to execute sp_rename for renaming existing column in our tables but it seems not working inside the stored procedure.So here's the script. ALTER PROCEDURE [dbo].[uspRenameTableColumn]ASDECLARE @renameTableColumn varchar(5000)SET @renameTableColumn = N' sp_rename ''tblSample.newcolumn'',''oldcolumn'',''column'''EXEC @renameTableColumnGOWhen I run it using the query editor, the result would be "Command(s) completed succesfully" So I assumed it would be fine.But when I try to execute it..EXEC uspRenameTableColumn"It throws back an error saying..."Msg 2812, Level 16, State 62, Procedure uspRenameTableColumn, Line 7Could not find stored procedure ' sp_rename 'tblSample.newcolumn','oldcolumn','column''. "Is there something wrong with the syntax or is there another way around to rename an existing field besides sp_rename?Your answer would be a great help. Thanks in advance.  |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-03 : 06:32:46
|
try putting braces after execALTER PROCEDURE [dbo].[uspRenameTableColumn]ASDECLARE @renameTableColumn varchar(5000)SET @renameTableColumn = N' sp_rename ''tblSample.newcolumn'',''oldcolumn'',''column'''EXEC (@renameTableColumn)GO |
 |
|
|
clerus
Starting Member
8 Posts |
Posted - 2008-12-03 : 20:22:49
|
Solved!! Thanks a lot! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-03 : 23:40:51
|
You're welcome |
 |
|
|
|
|
|