Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Fix Default Constraint Naming Expand / Collapse
Author
Message
Posted Thursday, October 7, 2010 9:59 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, September 1, 2014 3:35 AM
Points: 233, Visits: 463
Comments posted to this topic are about the item Fix Default Constraint Naming
Post #1000659
Posted Monday, October 11, 2010 8:59 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, December 4, 2013 3:54 PM
Points: 67, Visits: 230
The link to "sql.soendergaard.info" says "no scripts found".
Post #1002236
Posted Tuesday, October 12, 2010 1:07 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, September 1, 2014 3:35 AM
Points: 233, Visits: 463
use these links below or type the sql.soendergaard.info. in the address bar.

-- # You can download a complete install script here.
-- # http://files.soendergaard.info/Install_spFixColumnDefaultNaming_V2005-2008.sql
-- #
-- # I also have a test case script, which can be tried out in tempdb
-- #
-- # http://files.soendergaard.info/TestCasesOnly_spFixColumnDefaultNaming_V2005-2008.sql
Post #1002577
Posted Tuesday, October 12, 2010 9:22 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, December 4, 2013 3:54 PM
Points: 67, Visits: 230
Thanks.
Post #1002927
Posted Tuesday, February 22, 2011 11:40 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, December 3, 2014 5:45 AM
Points: 49, Visits: 191
Just used this last night. Fixed 4,500 naming violations. Wow. I had no idea people here were so bad at keeping up with our internal naming conventions. Stuff like default constraints get ignored every time!

I have to say, thank you very much for providing this script.

Overall, this was one of the easiest scripts I ever used and I was in and out in 5 minutes. Beautiful.

My only "missing feature" complaint would be that it doesn't let me deploy this to a "dbacode" database and provide a @Database parameter to say which database to run it in.

My only "bug report" complaint is that the script can't handle situations where it is renaming a default constraint to one already in the database. Usually this happens when people rename columns. I personally don't mind hunting down the offending problem, though, and fixing it manually.

Since I didn't want to keep this code in the general production databases, I added this afterward:
drop table dbautils.aliasrules
drop synonym dbautils.aliasrulessynonym
drop function dbautils.fnGetFilteredObjects
drop function dbautils.fnGetFilteredTables
drop function dbautils.fnGetObjectAliases
drop function dbautils.fnStringList2Table
drop procedure dbautils.spFixColumnDefaultNaming
drop schema dbautils

Post #1067790
Posted Friday, March 18, 2011 12:34 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, September 1, 2014 3:35 AM
Points: 233, Visits: 463
Thanks for the feedback.

Your are right with the issue with renamed columns, I have already runned into it, but it is not easy to fix, as it would need to be aware of the changed it is going to do, and with defaults matching other columns. Because of this I decided people should tweak the scripts themselves

I would also like to have every dba proc's in one database, but it is not possible to do dynamic sql in table valued functions. This means that all my renaming sproces would have to duplicate the TVF code into the sproc sometimes numerous times, and that would make code reuse and maintenance impossible.

The reason I have to use dynamic code in TVF, is because I query sys tables a lot, and those contain local database schema information only, hense the need for dynamic sql. I also use the TVF alot in other unpublished script at work. It would have been nice if Transact SQL supported the ability to have functions inside sprocs, which can only be called from the sproc. Kinda like functions declared in functions as in pascal
Post #1080631
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse