Posted by
MS Sql Server - Tips and Tricks
Published by: Cristiano Ghersi

MS Sql Server - Tips and Tricks

These are some very useful scripts that I created some years ago. I always use them to maintain my DB objects...

SQL SERVER: Create tables, with PK and FK

by cristiano.ghersi

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

/********************* DROP ALL FOREIGN KEYS ***********************/

DECLARE fk CURSOR FOR

SELECT t1.name, t2.name AS fkTable, t3.name ...