Rename Object not supported in Azure SQL Data Warehouse?
Asked Answered
U

2

6

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?

Umber answered 26/8, 2015 at 20:52 Comment(0)
U
10

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;
Umber answered 26/8, 2015 at 20:52 Comment(2)
Quick Update - the fix for this is coming within the next 2 weeks!Umber
Quick FYI - this fix only supports renaming a table within the same schema.Umber
V
0

In case someone else is looking at the time. It posible now in Azure Synapse Analytics, formely Azure SQL Datawarehouse; you can go with:

ALTER DATABASE AdventureWorks2012
MODIFY NAME = Northwind;
Viipuri answered 20/7, 2021 at 4:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.