It's nice to be able to predict the name of a primary key constraint based on the name of the table it constrains, but often times during the design of a database, we simply don't have time to worry about such things.
Below is a quick T-SQL script which helps to modify all primary key constraints so that they are named according with the table they belong to...
e.g. the table Dim.Sales will have it's primary key renamed to PK_Dim_Sales
To use the script, paste it into management studio, then:
Below is a quick T-SQL script which helps to modify all primary key constraints so that they are named according with the table they belong to...
e.g. the table Dim.Sales will have it's primary key renamed to PK_Dim_Sales
To use the script, paste it into management studio, then:
- press CTRL+T to have the output go to text
- press F5 to run the script
- Cut'n'Paste the query results into a new query window
- press F5 again to run the new query
Comments