Skip to main content

Posts

Showing posts with the label Naming Convention

4 level Object Name in SQL Server

There are four levels in the naming convention for any SQL Server object [ServerName.[DatabaseName.[SchemaName.]]]ObjectName Schema Name (or Ownership) --the object created is assigned to a schema rather than an owner. Whereas an owner related to one particular login, a schema can now be shared across multiple logins, and one login can have rights to multiple schemas --For object not belonging to default schema state, use the schema name of your object. The Default Schema: dbo::::::::::::::::::::::::::::: --for user of a database MySchema(login name) a table my.table created will have a ownerqualified object name would be MySchema.MyTable. So to access this table we need to use the name MySchema.MyTable (as this is created by a user) --for database owner fred, a table created as myTable , ownerqualified object name would be dbo.MyTable. ****as dbo also happens to be the default owner, any user could just refer to the table as MyTable. --sa (sysadmin role)will always ha...

SQL - Naming Convention

Naming Convention in SQL Stored Procedure.   sp<Application Name>_[<group name >_]<action type><table name or logical instance> Where action is: Get, Delete, Update, Write, Archive, Insert… i.e. verb  Example: spApplicationName_GetUserDetails        spApplicationName_UpdateEmails Note :Do not prefix stored procedure names with “SP_”, as “SP_” is reserved for system stored procedures. Triggers: TR_<TableName>_<action><description>  Example: TR_Emails_LogEmailChanges , TR_UserDetails_UpdateUserName Indexes :  IX_<tablename>_<columns separated by_>  Example: IX_UserDetails_UserID Primary Key : PK_<tablename>  Example: PK_UserDetails PK_ Emails Foreign Key : FK_<tablename_1>_<tablename_2>  Example: FK_UserDetails_Emails Default:  DF_<table name>_<column name>  Example: DF_ UserDetails _UserName Tables, Views, Stored Procedur...