Safety of renaming PKs, FKs, etc

  • The developers did not name any of their Primary Keys, Foreign Keys, Defaults or Indexes when they scripted tables.  As a result, SQL Server generated random unique names.  These names make it difficult to compare objects across databases for consistency and also make it difficult to install scripted changes across a wide spectrum of systems which are supposed to be identical.

    As a result, I would like to run scripts, such as the following, to rename the objects to a standard pattern:

    EXECUTE sp_rename 'PK__Tbl_DTM_INIData__5091BB2E', 'PK_Tbl_DTM_INIData', 'OBJECT'

    EXECUTE sp_rename 'PK__Tbl_DTM_ININames__2C545AB8', 'PK_Tbl_DTM_ININames', 'OBJECT'

    EXECUTE sp_rename 'PK__Tbl_DTM_INIStati__5185DF67', 'PK_Tbl_DTM_INIStatistic', 'OBJECT'

    EXECUTE sp_rename 'PK__Tbl_EmailDistrib__2D487EF1', 'PK_Tbl_EmailDistributionList', 'OBJECT'

    EXECUTE sp_rename 'PK__Tbl_EmailInforma__2E3CA32A', 'PK_Tbl_EmailInformation', 'OBJECT'

    I ran the scripts on our QA server with no obvious ill affects but thought it would be wise to see if anyone is aware of any adverse affects related to renaming PK, FKs, IXs or Defaults.

    Thanks!

     

  • SQL Server will not have any issues with you renaming these "things" using sp_rename.

  • Thanks Happy - I appreciate the confirmation......

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply