Community

Script all Primary Keys, Unique Constraints and Foreign Keys in a SQL Server database using T-SQL

(Percy Reyes) As SQL Server DBAs we may need to generate a script for the creation of all Primary Keys, Unique and Foreign Key constraints. We know with the SQL Server native tools that there is not a way to meet this need all at the same time.