SQL Server: drop table cascade equivalent?

Sinaesthetic picture Sinaesthetic · Feb 1, 2011 · Viewed 74.8k times · Source

In oracle, to drop all tables and constraints you would type something like

DROP TABLE myTable CASCADE CONSTRAINTS PURGE;

and this would completely delete the tables and their dependencies. What's the SQL server equivalent??

Answer

missaghi picture missaghi · Mar 30, 2011

In SQL Server Management Studio, go to Options / SQL Server Object Explorer / Scripting, and enable 'Generate script for dependent objects'. Then right click the table, script > drop to > new query window and it will generate it for you.