Little SQL Server Tricks: Rename Default Constraints

One would assume that renaming a default constraint should work the same way as renaming a primary key. For some unknown reason that was not the case as I had to fix the (dynamically generated) names of default constraints. The format that worked at last was this one:

Without the N in front of the names (that turns it explicitly into a nvarchar), I got error messages like this one:

Either the parameter @objname is ambiguous or the claimed @objtype (OBJECT) is wrong.

If you encounter reluctant constraints, try putting an N in front of the name first. Maybe it will help you too.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.