﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / Naming Convention for UDF's, Views and SP's / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 11:01:33 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Jeff Moden (2/13/2013)[/b][hr][quote][b]ScottPletcher (2/13/2013)[/b][hr]I wouldn't use a separate schema, first of all because of the security considerations: you'll break the ownership chain, thus forcing a lot more security checks on objects.[/quote]I believe that's one of the main purposes of schemas. Don't get me wrong...  I'm a frequent flyer of the "dbo only" club but, I have to ask, what's wrong with breaking the ownership chain when that's normally why someone would make separate schemas?[/quote]He clearly stated his reason for putting lookup tables into a separate was [b]not[/b] for security reasons, but to separate the table names from the main list; yes, that's a bizarre reason for a separate schema, but stated clearly as such nonetheless.  I don't see the need to provide extra, separate security for code lookup tables only.  Since when you GRANT SELECT on the main table, you have to remember to also GRANT SELECT on, say, the state code lookup table ... that doesn't seem worthwhile to me as a use for schemas.</description><pubDate>Thu, 14 Feb 2013 08:56:08 GMT</pubDate><dc:creator>ScottPletcher</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>As a former member of the dbo only club who initially used schemas for organizational purposes there are two lessons learned for me. There may be performance implications (probably negligible) because of the security checks.Ownership chains need to be addressed. I didn't previously know what they were. My development may be marginally and some what inadvertently more secure. There also is a bit more development overhead configuring security because of the ownership chain issues and a bit more complexity...</description><pubDate>Wed, 13 Feb 2013 22:16:06 GMT</pubDate><dc:creator>Chrissy321</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]ScottPletcher (2/13/2013)[/b][hr]I wouldn't use a separate schema, first of all because of the security considerations: you'll break the ownership chain, thus forcing a lot more security checks on objects.[/quote]I believe that's one of the main purposes of schemas. Don't get me wrong...  I'm a frequent flyer of the "dbo only" club but, I have to ask, what's wrong with breaking the ownership chain when that's normally why someone would make separate schemas?</description><pubDate>Wed, 13 Feb 2013 21:19:36 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Grant Fritchey (2/13/2013)[/b][hr]I hope no one is shocked when I basically agree with you. I like the concept of grouping through words, but clear language, not embedded codes.[/quote]I'll strongly second that.  Sorry I wrote so much under your post.  Most of it wasn't as a result of your post.  I just wanted to give folks a stong hint as to how I've made my life a whole lot easier.</description><pubDate>Wed, 13 Feb 2013 21:10:57 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]ScottPletcher (2/13/2013)[/b][hr][quote][b]Grant Fritchey (2/13/2013)[/b][hr]Ever is probably an over-reaction, but in general these types of naming conventions just don't make sense. How is tblInvoices easier to understand than Invoices? How is it more clear? Further, when you get hit by a bus, what does it communicate to the next person who takes over your job. I just do not see it. I'll give you an exception I have used and that's for lookup data. You know, the little name/value pair tables that are just there to enforce select lists? On those I've used c_TableName. The 'c_' stood for Code tables. It served two purposes. It made them all group together within SSMS, and it differentiated these tables from real system tables. However, now, I wouldn't even do that. I'd put them into a separate schema but with standard names. It would serve the same purpose but improve the overall readability. Instead of c_ which means nothing unless I tell you what it means, I could use Code.TableName or Lookup.TableName which makes things more clear.Naming standards should improve clarity and communication. Specialized abbreviations just don't add to the clarity. In fact, they tend to reduce it. But, this is one of those things that comes down to preference, not a technical reason. So if it works for you, go for it. But it's not a standard I'd support given the choice.[/quote]I wouldn't use a separate schema, first of all because of the security considerations: you'll break the ownership chain, thus forcing a lot more security checks on objects.[/quote]Don't you need security considerations to well have security? Wouldn't breaking the ownship chain foster security since permissions would have to be explicitly granted.</description><pubDate>Wed, 13 Feb 2013 13:56:33 GMT</pubDate><dc:creator>Chrissy321</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>Just imagine if SQL itself tried to use all these prefixes?  That would be a royal pain!In general they use the prefix to logically group things, such as sys.dm_db_*, sys.dm_os_*, etc..Something like sys.vw_dm_db_1 and sys.tbl_dm_db_2 would be a nightmare to try to correlate.Or sp_sel_configure [i]and[/i] sp_set_configure [i]vs just[/i] sp_configure.</description><pubDate>Wed, 13 Feb 2013 13:55:56 GMT</pubDate><dc:creator>ScottPletcher</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]RonKyle (2/13/2013)[/b][hr][quote]Also, it's extremely inconsistent unless you also name all your tables tblXXX (and DO NOT, EVER, do that, ).[/quote]Why would you never do this?  I've seen dimension tables prefixed Dim and fact tables prefixed Fact.  I use dtbl and ftbl.  With my tables, I have tbl, tlkp, trel, xtbl and stbl.  I find this very useful when going back to the design long after it's created to understand what I've done.  As for the stored procedures, I'll use add_, tfm_, sel_ and others.  Again, this helps me remember it's purpose when going back to it later.  I don't have many views, but it helps to have at least vw_ if only to distinguish it from tables.  I've been doing this a long time and seen the benefits.  Without some real factual reason, I don't think it's a good idea to tell someone to never ever use the system.[/quote]So what happens when an sel_ proc gets changed to also do adds?  What do you name a proc originally does multiple functions?  Let's admit it: the object name will [i]never[/i] be changed later, no matter how its functionality changes.You can, and should!, easily document that info lots of other ways that don't interfere with the use and management of the underlying SQL objects.</description><pubDate>Wed, 13 Feb 2013 13:49:59 GMT</pubDate><dc:creator>ScottPletcher</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Grant Fritchey (2/13/2013)[/b][hr]Ever is probably an over-reaction, but in general these types of naming conventions just don't make sense. How is tblInvoices easier to understand than Invoices? How is it more clear? Further, when you get hit by a bus, what does it communicate to the next person who takes over your job. I just do not see it. I'll give you an exception I have used and that's for lookup data. You know, the little name/value pair tables that are just there to enforce select lists? On those I've used c_TableName. The 'c_' stood for Code tables. It served two purposes. It made them all group together within SSMS, and it differentiated these tables from real system tables. However, now, I wouldn't even do that. I'd put them into a separate schema but with standard names. It would serve the same purpose but improve the overall readability. Instead of c_ which means nothing unless I tell you what it means, I could use Code.TableName or Lookup.TableName which makes things more clear.Naming standards should improve clarity and communication. Specialized abbreviations just don't add to the clarity. In fact, they tend to reduce it. But, this is one of those things that comes down to preference, not a technical reason. So if it works for you, go for it. But it's not a standard I'd support given the choice.[/quote]I wouldn't use a separate schema, first of all because of the security considerations: you'll break the ownership chain, thus forcing a lot more security checks on objects.</description><pubDate>Wed, 13 Feb 2013 13:48:08 GMT</pubDate><dc:creator>ScottPletcher</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote]As to "usp": it is illogical. The "sp_" in system procs stands for "special". So for a proc named "usp", why is this user proc "special" from other user procs?? Now, sometimes you need to create your owned stored procs with "sp_" to make them "special" in the same way that sys procs are "special", but that's a different subject [/quote]I was always under the impression that usp stood for user stored procedure.  I would never recommend using sp for a user stored procedure to avoid any confusion the the stored procs that are inherent to the master database.My stored procs have a number of possible prefixes, but I think the comment about suffixes is also valid.  I would still have concerns to have no naming convention.  I've seen too many disorganized systems that are difficult to figure out.  I try not to be wedded to outdated ways, but on the other hand I'm not sure some just need to learn to take more care and think of their successors.</description><pubDate>Wed, 13 Feb 2013 13:30:53 GMT</pubDate><dc:creator>RonKyle</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>Given that the q said "why should they not be [b]prefixed[/b]", I think it's OK.  It shouldn't be done because it does slow down name lookup for those objects, which of course must be done every time a query plan is built.As others have noted, I dislike adding "_vw" to views for the same reason: at some future point a view might become a table, and a table might become a view.As to "usp": it is illogical.  The "sp_" in system procs stands for "special".  So for a proc named "usp", why is this user proc "special" from other user procs??  Now, sometimes you need to create your owned stored procs with "sp_" to make them "special" in the same way that sys procs are "special", but that's a different subject :-).</description><pubDate>Wed, 13 Feb 2013 10:10:02 GMT</pubDate><dc:creator>ScottPletcher</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Jeff Moden (2/13/2013)[/b][hr]On the other hand, I don't necessarily want all of those lookup tables to group together.  I'd rather have them group together with the tables they support.  Although I hate the idea of using Hungarian notation to identify the object type, I'm all for relational prefixes that identify the main process they're associated with.  For example, if I'm dealing with loans, I'll have a table call "Loan".  I'll have a lookup table for loan type and rather than calling it c_LoanType or putting it in a separate schema, which will appear quite the physical distance from the Loan table in the object explorer in the size databases I work with, I'll call the table "LoanType" so it's very close or maybe even adjacent to the "Loan" table in the object explorer.  I also have an audit table for the loan table.  Rather than grouping all the audit tables together by using the "Audit*" naming convention, I call the table "LoanAudit" so that you can easily tell there's an audit table for the "Loan" table just by having the same leading prefix as the main table name.Shifting gears, there are two schools of thought.  One is to prefix object names using Hungarian notation and, trying desperately to not come across like Joe Celko, I just see no merit in that especially since things can change.  The other school of thought is to group names by the functionality they have according to functionally related areas (Loan, LoanType, LoanAudit, Customer, CustomerType, CustomerAudit, for example) and THAT type of prefix makes a lot of sense.There's also more than one type of database which adds to the "It Depends" notion of prefixing.  I can easily see how object name prefixes, such as "Dim" or "Fact", would be extremely helpful in a data warehouse.  The problem there is that some people overdo it IMHO.  For example, it's not likely that I'd name a general purpose Calendar table "Dim_Calendar".  Maybe "Util_Calendar" but not "Dim_Calendar".  I still lean away from using prefixes of such a nature though because they would physically separate (for example) related tables such as "Fact_Loan" from "Dim_LoanType".  I'll probably have every DW expert in the world yell at me because it violates status quo naming conventions but if forced to identify a table as either a dimension table or a fact table, I'd rather use suffixes so that all the (for example) Loan related tables are physically grouped together in object explorer no matter if they're Dim or Fact or something else.  The exception to that rule would be general purpose utility tables that would get the "Util" prefix or live in the "Util" schema for obvious separation.With the possible exception of Hungarian notation (again, just my opinion but should never be used), it truly "Depends".  That, not withstanding, the key for everyone, whether it's good or bad in their opinion, is to follow the "standard" used in whatever shop you're working in.  Doesn't matter whether you're an FTE or a consultant, follow what is currently in place for a given database because consistency if very important is naming conventions.Again, just expressing an opinion here.[/quote]I hope no one is shocked when I basically agree with you. I like the concept of grouping through words, but clear language, not embedded codes.</description><pubDate>Wed, 13 Feb 2013 09:38:41 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote]I'll probably have every DW expert in the world yell at me because it violates status quo naming[/quote]Consider this a "Yelling" Jeff ;-)[quote]That, not withstanding, the key for everyone, whether it's good or bad in their opinion, is to follow the "standard" used in whatever shop you're working in[/quote]That was actually my answer, almost word for wordAndy</description><pubDate>Wed, 13 Feb 2013 08:49:01 GMT</pubDate><dc:creator>Andy Hyslop</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Michael Valentine Jones (2/13/2013)[/b][hr][quote][b]Andy Hyslop (2/11/2013)[/b...Why should User Defined Functions not be prefixed UDF or udf, views not Prefixed with VW or vw and Stored Procedures not USP or usp...[/quote]That is an odd question to show up on a SQL test.  There are no technical reasons (that I know of) why you can't do that, or why the application would work better.I have seen many applications that used UDF, VW, and USP, but I have never seen any actual application problems caused by this.Of course there are many good reasons not to use them that others have pointed out, but in the end they amount to style preference, standards, ease of coding, ease of understanding, etc. [/quote]I completely agree, it was unusual and that's why it threw me....totally!!! :-SI really couldn't think of a valid reason and my answer reflected as such..Although I am seeing some valid reasons why not to and am enjoying the discussion I just cant see any real impact that necessitates the term "must not be used"...:crazy:</description><pubDate>Wed, 13 Feb 2013 08:44:10 GMT</pubDate><dc:creator>Andy Hyslop</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Grant Fritchey (2/13/2013)[/b][hr]Ever is probably an over-reaction, but in general these types of naming conventions just don't make sense. How is tblInvoices easier to understand than Invoices? How is it more clear? Further, when you get hit by a bus, what does it communicate to the next person who takes over your job. I just do not see it. I'll give you an exception I have used and that's for lookup data. You know, the little name/value pair tables that are just there to enforce select lists? On those I've used c_TableName. The 'c_' stood for Code tables. It served two purposes. It made them all group together within SSMS, and it differentiated these tables from real system tables. However, now, I wouldn't even do that. I'd put them into a separate schema but with standard names. It would serve the same purpose but improve the overall readability. Instead of c_ which means nothing unless I tell you what it means, I could use Code.TableName or Lookup.TableName which makes things more clear.Naming standards should improve clarity and communication. Specialized abbreviations just don't add to the clarity. In fact, they tend to reduce it. But, this is one of those things that comes down to preference, not a technical reason. So if it works for you, go for it. But it's not a standard I'd support given the choice.[/quote]On the other hand, I don't necessarily want all of those lookup tables to group together.  I'd rather have them group together with the tables they support.  Although I hate the idea of using Hungarian notation to identify the object type, I'm all for relational prefixes that identify the main process they're associated with.  For example, if I'm dealing with loans, I'll have a table call "Loan".  I'll have a lookup table for loan type and rather than calling it c_LoanType or putting it in a separate schema, which will appear quite the physical distance from the Loan table in the object explorer in the size databases I work with, I'll call the table "LoanType" so it's very close or maybe even adjacent to the "Loan" table in the object explorer.  I also have an audit table for the loan table.  Rather than grouping all the audit tables together by using the "Audit*" naming convention, I call the table "LoanAudit" so that you can easily tell there's an audit table for the "Loan" table just by having the same leading prefix as the main table name.Shifting gears, there are two schools of thought.  One is to prefix object names using Hungarian notation and, trying desperately to not come across like Joe Celko, I just see no merit in that especially since things can change.  The other school of thought is to group names by the functionality they have according to functionally related areas (Loan, LoanType, LoanAudit, Customer, CustomerType, CustomerAudit, for example) and THAT type of prefix makes a lot of sense.There's also more than one type of database which adds to the "It Depends" notion of prefixing.  I can easily see how object name prefixes, such as "Dim" or "Fact", would be extremely helpful in a data warehouse.  The problem there is that some people overdo it IMHO.  For example, it's not likely that I'd name a general purpose Calendar table "Dim_Calendar".  Maybe "Util_Calendar" but not "Dim_Calendar".  I still lean away from using prefixes of such a nature though because they would physically separate (for example) related tables such as "Fact_Loan" from "Dim_LoanType".  I'll probably have every DW expert in the world yell at me because it violates status quo naming conventions but if forced to identify a table as either a dimension table or a fact table, I'd rather use suffixes so that all the (for example) Loan related tables are physically grouped together in object explorer no matter if they're Dim or Fact or something else.  The exception to that rule would be general purpose utility tables that would get the "Util" prefix or live in the "Util" schema for obvious separation.With the possible exception of Hungarian notation (again, just my opinion but should never be used), it truly "Depends".  That, not withstanding, the key for everyone, whether it's good or bad in their opinion, is to follow the "standard" used in whatever shop you're working in.  Doesn't matter whether you're an FTE or a consultant, follow what is currently in place for a given database because consistency if very important is naming conventions.Again, just expressing an opinion here.</description><pubDate>Wed, 13 Feb 2013 08:39:52 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Andy Hyslop (2/11/2013)[/b...Why should User Defined Functions not be prefixed UDF or udf, views not Prefixed with VW or vw and Stored Procedures not USP or usp...[/quote]That is an odd question to show up on a SQL test.  There are no technical reasons (that I know of) why you can't do that, or why the application would work better.I have seen many applications that used UDF, VW, and USP, but I have never seen any actual application problems caused by this.Of course there are many good reasons not to use them that others have pointed out, but in the end they amount to style preference, standards, ease of coding, ease of understanding, etc. </description><pubDate>Wed, 13 Feb 2013 08:28:35 GMT</pubDate><dc:creator>Michael Valentine Jones</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]RonKyle (2/13/2013)[/b][hr][quote]Also, it's extremely inconsistent unless you also name all your tables tblXXX (and DO NOT, EVER, do that, ).[/quote]Why would you never do this?  I've seen dimension tables prefixed Dim and fact tables prefixed Fact.  I use dtbl and ftbl.  With my tables, I have tbl, tlkp, trel, xtbl and stbl.  I find this very useful when going back to the design long after it's created to understand what I've done.  As for the stored procedures, I'll use add_, tfm_, sel_ and others.  Again, this helps me remember it's purpose when going back to it later.  I don't have many views, but it helps to have at least vw_ if only to distinguish it from tables.  I've been doing this a long time and seen the benefits.  Without some real factual reason, I don't think it's a good idea to tell someone to never ever use the system.[/quote]I know what you mean about wanting to know the purpose. This is actually quite useful. I prefer to use a suffix for this type of thing instead of a prefix. This serves two main advantages. First it will keep like items grouped in SSMS. And secondly I find it makes it far easier to code with. Say you have a Product and you need the basic CRUD sprocs. With your naming convention you would have add_Product, sel_Product, del_Product, upd_Product. Those are certainly clear what they do but they are hard to code with and in SSMS you will have stuff scattered all over. If instead you moved it to the end like this. Product_add, Product_sel, Product_del, Product_upd. Now when you are coding you think I need the Product sproc, intellisense will now show you only those that start with Product. For me I also think first of the object I am working with and then what I need to do to it. Just my 2¢.</description><pubDate>Wed, 13 Feb 2013 07:49:50 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>Ever is probably an over-reaction, but in general these types of naming conventions just don't make sense. How is tblInvoices easier to understand than Invoices? How is it more clear? Further, when you get hit by a bus, what does it communicate to the next person who takes over your job. I just do not see it. I'll give you an exception I have used and that's for lookup data. You know, the little name/value pair tables that are just there to enforce select lists? On those I've used c_TableName. The 'c_' stood for Code tables. It served two purposes. It made them all group together within SSMS, and it differentiated these tables from real system tables. However, now, I wouldn't even do that. I'd put them into a separate schema but with standard names. It would serve the same purpose but improve the overall readability. Instead of c_ which means nothing unless I tell you what it means, I could use Code.TableName or Lookup.TableName which makes things more clear.Naming standards should improve clarity and communication. Specialized abbreviations just don't add to the clarity. In fact, they tend to reduce it. But, this is one of those things that comes down to preference, not a technical reason. So if it works for you, go for it. But it's not a standard I'd support given the choice.</description><pubDate>Wed, 13 Feb 2013 07:18:19 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote]Also, it's extremely inconsistent unless you also name all your tables tblXXX (and DO NOT, EVER, do that, ).[/quote]Why would you never do this?  I've seen dimension tables prefixed Dim and fact tables prefixed Fact.  I use dtbl and ftbl.  With my tables, I have tbl, tlkp, trel, xtbl and stbl.  I find this very useful when going back to the design long after it's created to understand what I've done.  As for the stored procedures, I'll use add_, tfm_, sel_ and others.  Again, this helps me remember it's purpose when going back to it later.  I don't have many views, but it helps to have at least vw_ if only to distinguish it from tables.  I've been doing this a long time and seen the benefits.  Without some real factual reason, I don't think it's a good idea to tell someone to never ever use the system.</description><pubDate>Wed, 13 Feb 2013 07:01:21 GMT</pubDate><dc:creator>RonKyle</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>Thanks all for the replies - most helpful :-)I have never prefixed tables with tbl but I have prefixed usp's and viewsIt just seemed like an odd question the way it was phrased, I think the word never prefix was a little strong and that threw me a little.From what I can gather from the conversation, yes it makes sense not to do so (and I won't from now on)  and there are good reasons not to however as I said never was a little strong, is there a huge impact (for example to coin Jeffs phrase writing RBAR when set based will do the job better) then no?</description><pubDate>Tue, 12 Feb 2013 04:02:26 GMT</pubDate><dc:creator>Andy Hyslop</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Chrissy321 (2/11/2013)[/b][hr]I have never been a tbl-er but I have been a usp-er.Lately I put everything in a schema. Is this a reasonable statement as far as a best practice? Always put all objects in a schema besides dbo.Educational comments most welcome....[/quote]It depends. If I have discrete sets of functionality, then I break things up into schemas. But it needs to be substantial. I've never created a schema for 2 or 3 tables alone. If there really isn't any way to differentiate the parts of an application or if the application is small, then I just leave it in dbo. Since schema ownership can make things easier to manage, I find it helpful for big databases.</description><pubDate>Tue, 12 Feb 2013 03:43:08 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>The databases I work on usually belong to clients and already have a schema. Often these instances are full of third-party objects with all kinds of naming conventions. So even though it does involve an extra bit of typing (isn't that what Red Gate SQL Prompt is for?), I use unique project-based prefixes so my objects will at least all be grouped together when I'm working in SSMS. Also, though I'm starting to use scalar functions less and less, I still like to prefix them with "svf" or "tvf" so I know what output to expect. I'm not adverse to long descriptive names though...I think when it's a year or two later and I have to come back and look at something I hardly remember I'm always glad I used intelligible names. That includes variable names within procedures as well.I waver back-and-forth inconsistently when naming columns base on datatype such as "intGender" vs "strGender" when it may not be obvious. Lately I tend to skip the camel casing and if it says EmployeeID then it's an integer and if EmployeeDesc then obviously it's a string. I have one current client who is bat-@#$% crazy about camel-casing EVERYTHING. So it's bitDog this, dtCat that, guidSession until it gets tiresome. He also thinks uniqueidentifiers are the best thing to use for primary keys on every table...oh, crap, now I'm ranting...don't get me started...:-P </description><pubDate>Mon, 11 Feb 2013 21:40:24 GMT</pubDate><dc:creator>Steven Willis</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>I put most everything in the DBO schema, Crissy.  The only time I deviate from that is for utility and scratch objects.  Of course, most of the work I do is at the batch level and what little I do for the front end can easily tolerate not using a bunch of schemas because I go for the next level of "security by separation" by keeping things in different databases.</description><pubDate>Mon, 11 Feb 2013 16:08:53 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>I have never been a tbl-er but I have been a usp-er.Lately I put everything in a schema. Is this a reasonable statement as far as a best practice? Always put all objects in a schema besides dbo.Educational comments most welcome....</description><pubDate>Mon, 11 Feb 2013 16:03:50 GMT</pubDate><dc:creator>Chrissy321</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>Synonyms won't work there.  Remember, the structure of the table has been modified but the GUIs have to think it hasn't.  This is especially true when you add a column but the app has some poorly formed embedded code that does INSERT/SELECTs without and insert column-list.But, point taken.  Why would anyone use Hungarian notation to name a synonym? :-P</description><pubDate>Mon, 11 Feb 2013 16:03:17 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Jeff Moden (2/11/2013)[/b][hr][quote][b]Andy Hyslop (2/11/2013)[/b][hr]I recently has to take a written SQL test for a client and one of the questions got me stumped (from memory was something like this):Why should User Defined Functions not be prefixed UDF or udf, views not Prefixed with VW or vw and Stored Procedures not USP or uspI couldn't come up with a reason for not using these naming conventions..:crazy:Can anyone enlighten me?Andy[/quote]I agree with what has already been suggested but I have a cold, hard reason for not doing it for tables and views.  There have been many times where I've needed to change the structue of a table but couldn't do so because of some bad coding practices on the front end.  To trick the front end into not seeing the change, I changed the table name to something else and then made a view using the original table name.  I don't know about you but it kind of defeats the whole purpose to have a view with a prefix of "tbl". ;-)[/quote]Synonyms could probably get around this type of scenario to Jeff. Then you don't need a view either. :-P  I do agree though that object prefixes are not a good idea.</description><pubDate>Mon, 11 Feb 2013 15:50:33 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>Just to reinforce what Jeff has said. I have also found views with a prefix of "tbl", I think for the same reasons - something started off as a table and the structure evolved over the years until it was changed to a view - so it may sound daft but it does happen.So to me I would absolutely avoid:tables with the prefix tbl stored procs prefixed usp_ - it is just pointless lettersdata types included in column namesMike John</description><pubDate>Mon, 11 Feb 2013 15:50:06 GMT</pubDate><dc:creator>Mike John</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>[quote][b]Andy Hyslop (2/11/2013)[/b][hr]I recently has to take a written SQL test for a client and one of the questions got me stumped (from memory was something like this):Why should User Defined Functions not be prefixed UDF or udf, views not Prefixed with VW or vw and Stored Procedures not USP or uspI couldn't come up with a reason for not using these naming conventions..:crazy:Can anyone enlighten me?Andy[/quote]I agree with what has already been suggested but I have a cold, hard reason for not doing it for tables and views.  There have been many times where I've needed to change the structue of a table but couldn't do so because of some bad coding practices on the front end.  To trick the front end into not seeing the change, I changed the table name to something else and then made a view using the original table name.  I don't know about you but it kind of defeats the whole purpose to have a view with a prefix of "tbl". ;-)</description><pubDate>Mon, 11 Feb 2013 15:40:02 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>I do mostly agree with Grant and technically, all that data is available in the metadata and shouldn't need to be reflected in the object name. However, I am quite fond of having some sort of naming convention for views, as it's not visible at a glance that you're referencing a view rather than a table and I find there are less developer mistakes when they're obviously marked in the name (e.g. re-utilising views inappropriately rather than going back to the base tables).</description><pubDate>Mon, 11 Feb 2013 05:24:09 GMT</pubDate><dc:creator>HowardW</dc:creator></item><item><title>RE: Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>They all can be. Makes things sloppy in my opinion. However, if you are dealing very large numbers of objects, for example, I saw this with stored procedures when we had over 1000 of them, and they all have the same first several letters, it actually can slow down performance of the underlying system as it tries to find the proc name. Now, this was back on 2000 and some hardware that wasn't terribly beefy, but it is possible.Nah, the main reason I'd argue against that style notation is that it's VERY old school. Even most developers have tossed that object naming style for just using plain names for clarity. Also, it's extremely inconsistent unless you also name all your tables tblXXX (and DO NOT, EVER, do that, :w00t:).I just wouldn't because it reduces clarity and readability. Also, when I'm typing and anticipating my code completion to fill in the proc name or whatever, I know have to type about 6-8 characters instead of 3-5, slowing me down considerably.</description><pubDate>Mon, 11 Feb 2013 05:08:36 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>Naming Convention for UDF's, Views and SP's</title><link>http://www.sqlservercentral.com/Forums/Topic1418304-391-1.aspx</link><description>I recently has to take a written SQL test for a client and one of the questions got me stumped (from memory was something like this):Why should User Defined Functions not be prefixed UDF or udf, views not Prefixed with VW or vw and Stored Procedures not USP or uspI couldn't come up with a reason for not using these naming conventions..:crazy:Can anyone enlighten me?Andy</description><pubDate>Mon, 11 Feb 2013 04:11:51 GMT</pubDate><dc:creator>Andy Hyslop</dc:creator></item></channel></rss>