[Posting question from customer on an internal thread]
I tried to run the following commands in SQL DW:
RENAME OBJECT dbo.test TO test2
RENAME OBJECT test TO test2
Both failed with the following error:
No item by the name of '[DemoDB].[dbo].[test]' could be found in the current database 'DemoDB', given that @itemtype was input as '(null)'.
Is this a defect or is there a workaround that I can use?
You can use the sp_rename stored procedure or use SQL Server Management Studio by right clicking on the object and selecting rename. Another option is to create a new object and drop the old object. This could be any object that exists with SQL Server (table, stored procedure, trigger, etc.)
T-SQL statements related to availability groups are not supported by SQL Database, and the dynamic management views related to Always On Availability Groups are also not supported. For a list of the features that are supported and unsupported by SQL Database, see Azure SQL Database feature comparison.
To rename a database in Azure SQL Database, use the ALTER DATABASE (Azure SQL Database) statement. To rename a database in SQL Server, use the stored procedure sp_renamedb.
RENAME is now supported. In order to use rename object you must prefix the table you want to change with the schema name like this:
RENAME OBJECT x.T_New TO T;
Notice that there is no schema qualification on the target. This is because the renamed object must continue to reside inside the same schema. To transfer a table from one schema to another you need to use the following command:
ALTER SCHEMA dbo TRANSFER OBJECT::x.T_NEW;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With