DataBaseZone.com
Conrad Muller
Juneau, Alaska

Email: conrad at
databasezone
dot com

Simple Object Naming


Naming programming objects. These rules are applicable to all SQL Server objects and a good idea in any environment.

 
A Depreciated Object Naming Convention using prefixes:

This was a common object naming convention. Currently it is normally not used in new projects. This information is provided for people working on legacy projects which used this naming convention.

Suggestions for Variable Data Type Naming
 
Data type Prefix Example Note
String (Text) str strCity Text to 255 characters
Date/Time dtm dtmCreated Date and Time
Boolean bln blnIsNotNull Yes/No or True/False, two values
Byte byt bytMonth One Byte, values from 0 to +255
Integer int or i intCount or
iCount
Two Bytes; values from -32,768 to +32,767; No fractions
Long
(long integer)
lng lngDistance Four Bytes, values from
-2,147,483,648 to 2,147,483,647
Single sng sngPopulation Four Bytes single precision, floating point
Currency cur curTraded Fifteen digits to the left, four to the left. Fixed decimal place.
Double dbl dblClientID Eight Bytes
Decimal dec decMicroseconds Twelve Bytes
Object obj objConnection  
Variant vnt vntUserInput It can store numeric, string, date/time, Null, or Empty data
Error err errBadEmailAddress  

Another Older Object Naming Convention

This is an obsolete naming convention. Forms of this convention were widely used when programming tools made it hard to tell if you were looking at a database, a table, or a query in the object viewer. This convention also works best with simple projects where there is only one module.

I have included this section because there are many projects "out there" using it. Also, some people still use this convention. As you can see, some of the prefixes are specific to development in Microsoft Access, which is natural, since it was Access developers who popularized this form of naming.

Type of Object Name Prefix Example Access Example
Table tbl tbl_last_name tblLastName
Form frm frm_pet frmPet
Sub Form sfrm fsfr_visit fsfrVisit
Label lbl lbl_last_name lblLastName
TextBox txt txt_last_name txtLastName
Command Button cmd cmd_exit cmdExit
Report rpt rpt_invoice rptInvoice
Sub Report srpt rsrp_medication rsrpMedication
Query, Select qsel qsel_search qselSearch
Query, Append qapp qapp_customer qappCustomer
Query, Delete qdel qdel_out_of_date qdelOutOfDate
Query, Update qupd qupd_area_code qupdAreaCode
Query, MakeTable qmak qmak_tbl_visit qmakVisit
Macro mcr mcr_open_frm_search mcrOpenfrmSearch
Module, VBA bas bas_utlility basUtility

Object Naming Conventions; Details
 
Class Object Prefix
Table tbl
Query qry
Form frm
Report rpt
Macro mcr
Module bas
Subform/report s

Field Object Prefix
Currency cur
Date/Time dtm
Double dbl
Integer int
Long lng
Memo mem
Single sng
Text (string) str
Yes/No or boolean ysn or bln

 
Control object Prefix
Check Box chk
Combo Box cbo
Command Button cmd
Label lbl
List Box lst
Option Button opt
Text Box txt

My (Conrad Muller's) work on this page is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 2.5 License.

Home | Resume | Project Portfolio | Writings | Developer Resources | Contact Form