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

way to enforce object naming conventions? Expand / Collapse
Author
Message
Posted Tuesday, November 20, 2012 3:27 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 03, 2014 8:45 AM
Points: 22, Visits: 23
Hi,
i'm wondering if there is any way to enforce object naming conventions (using three-part identifiers) within views/functions/procedures ?

for example, use
insert into myBase.dbo.myTable

instead of
insert into dbo.myTable

or use
select * from myBase.dbo.myFunction()

instead of
select * from myBase..myFunction()

we have several sql2008 databases and several developers and although we have some (loose-ish) guidelines for naming conventions, they are not always adhered to.

i've read a little about policy-based management but i'm not clear if something like this can be achieved.

it seems to me the only way to ensure all developers adhere firmly to our naming conventions is to hold a staff meeting and drum it in to them!

perhaps someone could point me in the right direction ?

many thanks
Post #1386786
Posted Tuesday, November 20, 2012 3:31 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, August 28, 2013 2:37 AM
Points: 5,075, Visits: 4,834
There is no way to enforce a naming convention when your typing code but you can enforce object names where you have to create a table using a prefix for example all tables need to start tbl, all views need to start vw but that would only come into force when you create the object, not when you reference it in script.

If you want to ensure your developers reference an object mydatabase.myschema.myobject then you will need to drum it into them that this is the way that things are done.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1386791
Posted Tuesday, November 20, 2012 3:36 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 03, 2014 8:45 AM
Points: 22, Visits: 23
in the back of my mind i was hoping there was some simple way of coding it, but it looks like i'll be calling a meeting quite soon.
many thanks.
Post #1386792
Posted Tuesday, November 20, 2012 3:40 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:58 AM
Points: 5,077, Visits: 8,919
Are you sure you want to make that a universal rule? Bear in mind that if you rename your database, or if you like your code so much you decide to use it in a different database, you could end up having to do some serious refactoring.

John
Post #1386796
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse