Link to home
Start Free TrialLog in
Avatar of csehz
csehzFlag for Hungary

asked on

SQL - Rename global temporary table

Dear Experts,

Could you please advise about the syntax how to rename a table by an SQL statement?

Concretely in my test that table is a global temporary table, created by:
CREATE TABLE
	##TempTable (VendorNumber NVARCHAR(20), VendorName NVARCHAR(70));

Open in new window

where:
SELECT * FROM dbo.##TempTable

Open in new window

confirms that it has been created.

But trying the rename for that by syntax:
EXEC sp_rename [tempdb.dbo.##TempTable], [tempdb.dbo.##TempTableRenamed];

Open in new window

getting an error message that:

An invalid parameter or option was specified for procedure 'sys.sp_rename'.


Could you please advise what is wrong with the syntax concretely in this example?

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csehz

ASKER

Thanks learnt from the case