How to drop a table with foreign key constraint in SQL Server

187 Views Asked by At

I would like to drop a table with foreign key constraint and re-create the same table (with all the relationships) and with additional data (which I have from “Generate Scripts…”)

How can I do it? I'm using an Azure SQL Server.

If I disable the constraint, truncate the table, insert new data, and re-enable it? Will this work?

Any leads, please? Thanks.

1

There are 1 best solutions below

0
Viswanatha Swamy On

One of the ways is to create a .sqlproj. Inside this, you can create the tables, stored procedures, indexes, data population, and much more. The deployment from .sqlproj will take care of any changes you do to the data store. Please refer to the links below.

URL: https://learn.microsoft.com/en-us/azure/devops/pipelines/targets/azure-sqldb?view=azure-devops&tabs=yaml

https://learn.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-ver15