I created a global temp table like this -
CREATE TABLE
(Nos varchar(10) null)
Then try renaming the Nos column as follows:
EXEC sp_RENAME '##BigTable.Nos' , 'Numbers', 'COLUMN'
I got an error -
Either the parameter @objname is ambiguous or the
claimed @objtype (COLUMN) is wrong.
Why can this happen and how can I solve the problem?
EXTRA not quite related to the question, but for reference.
I want to add this - I tried to create a global temp table using a completely name like this -
CREATE TABLE [NotMyTempDataBase].[dbo].[
(Nos varchar(10) null)
Then I tried to rename it with -
EXEC tempdb.sys.sp_rename N'[NotMyTempDataBase].[dbo].[##BigTable].Nos',
N'Numbers', N'COLUMN';
Error - Qualified @oldname refers to a database other than the current database.
It is not right. I realized that the temporary table was created in the tempdb system database , although when creating it, a different database name is indicated.
use this instead -
CREATE TABLE [tempdb].[dbo].[
(Nos varchar(10) null)
- SQL: "tempdb" , tempdb.
EXEC tempdb.sys.sp_rename N'[tempdb].[dbo].[##BigTable].Nos',
N'Numbers', N'COLUMN';