November 20, 2012 at 3:27 am
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
November 20, 2012 at 3:31 am
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.
November 20, 2012 at 3:36 am
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.
November 20, 2012 at 3:40 am
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
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply