Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
BiJoe
Helper II
Helper II

ALTER SCHEMA in Synapse Warehouse

I would like to transfer tables to a different schema than [dbo] after loading it to a Warehouse with Dataflow gen 2. Is it safe to run ALTER SCHEMA in a SQL query in from Fabric Synapse Warehouse? 

 

T-SQL surface area - Microsoft Fabric | Microsoft Learn

1 ACCEPTED SOLUTION
v-nikhilan-msft
Community Support
Community Support

Hi @BiJoe 
Thanks for using Fabric Community.

While ALTER SCHEMA exists in Transact-SQL, it's not recommended to use it in a Fabric Synapse Warehouse for transferring tables between schemas. Here's why:

Limitations of ALTER SCHEMA in Fabric Synapse Warehouse:

  • Limited Functionality: Unlike SQL Server, Fabric Warehouse has limited functionality for modifying schema objects like tables using ALTER SCHEMA.
  • Compatibility Issues: Using ALTER SCHEMA might not be fully compatible with other data modification operations in Fabric Warehouse and could lead to unexpected behavior or errors.

I tried to repro using this SQL code:

vnikhilanmsft_0-1708936670965.png

The code ran successfully. The table's schema also got changed. But when Iam trying to load the data, its giving me an error.


vnikhilanmsft_1-1708936765805.png


So, I wouldnt suggest you to alter the schema. Instead create a clone of the table using the new schema. You can do this by following the below steps:

vnikhilanmsft_2-1708937059319.png

vnikhilanmsft_4-1708937256741.png

 

For more information please refer to this link:
https://learn.microsoft.com/en-us/fabric/data-warehouse/clone-table
This will create a copy of the table. You can delete the dbo.Table after creating the clone. 
Hope this helps. Please let me know if you have any further questions.



View solution in original post

1 REPLY 1
v-nikhilan-msft
Community Support
Community Support

Hi @BiJoe 
Thanks for using Fabric Community.

While ALTER SCHEMA exists in Transact-SQL, it's not recommended to use it in a Fabric Synapse Warehouse for transferring tables between schemas. Here's why:

Limitations of ALTER SCHEMA in Fabric Synapse Warehouse:

  • Limited Functionality: Unlike SQL Server, Fabric Warehouse has limited functionality for modifying schema objects like tables using ALTER SCHEMA.
  • Compatibility Issues: Using ALTER SCHEMA might not be fully compatible with other data modification operations in Fabric Warehouse and could lead to unexpected behavior or errors.

I tried to repro using this SQL code:

vnikhilanmsft_0-1708936670965.png

The code ran successfully. The table's schema also got changed. But when Iam trying to load the data, its giving me an error.


vnikhilanmsft_1-1708936765805.png


So, I wouldnt suggest you to alter the schema. Instead create a clone of the table using the new schema. You can do this by following the below steps:

vnikhilanmsft_2-1708937059319.png

vnikhilanmsft_4-1708937256741.png

 

For more information please refer to this link:
https://learn.microsoft.com/en-us/fabric/data-warehouse/clone-table
This will create a copy of the table. You can delete the dbo.Table after creating the clone. 
Hope this helps. Please let me know if you have any further questions.



Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Expanding the Synapse Forums

New forum boards available in Synapse

Ask questions in Data Engineering, Data Science, Data Warehouse and General Discussion.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayFBCUpdateCarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

Top Kudoed Authors