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 |
KlausEngel
Yak Posting Veteran
85 Posts |
Posted - 2011-02-21 : 17:00:36
|
I need to rename a column of a temporary table during a stored procedure. I've tried:USE TEMPDBGOEXEC sp_rename 'dbo.#temp.[OldColName]', '[NewColName]' which works fine if I run it outside of the sp, but when encapsulated in the sp I receive an error message because the USE command is not allowed with the sp.Any ideas how to get around that? |
|
jeffw8713
Aged Yak Warrior
819 Posts |
Posted - 2011-02-21 : 19:46:14
|
First, why are you renaming a column on a temp table? I wouldn't bother - since I could either create the temp table with the right column name, or rename the column on output.But, with that said - have you tried:Execute tempdb..sp_rename 'dbo.#temp.[OldColName]', '[NewColName]';Jeff |
|
|
|
|
|