Company: Link Technologies
Case No: L12476
Logged By: Sanjay (Link Technologies) on 04 Jun 2013 07:11PM
Priority: Not Applicable
Product: Other
Group: To be assigned
Time Taken: 0.00
Assigned To: Sanjay (Link Technologies)
Circulation: Sanjay
Resolve By: Tuesday, 04 June 2013 07:11 PM [3977 days since logged date]
Status: Closed
Subject: SQL Server Script Templates
Summary:    
Below are some script templates we use in our database build scripts:

Template script to add a new column to an existing table: in this example, we are adding a Type field with data type Varchar(50) to the HR_Vacancy Table

If Exists(Select * From Sys.Objects Where Object_Id = Object_Id(N'[dbo].[HR_VACANCY]') And Type = 'U')

And NOT Exists(Select * From Sys.Columns Where Name = 'Type' And Object_Id = Object_Id(N'[dbo].[HR_VACANCY]'))

Begin

Alter Table dbo.HR_VACANCY ADD Type VARCHAR(50) NULL

Print 'Added column Type varchar(50) on table HR_VACANCY'

End

GO


Procedure Comment Template

/*--- Summary----------------------------------------------------------------------------
Name: {Procedure Name}
Purpose: {Brief Descrition of the procedure}
Author: {Your name}
Created Date: {Date Created}
--- Dependencies ---List where this procedure is used and any links to other procedures

--- Business Rules --- List any business rules that may apply

--- Modification History---------------------------------------------------------------
Date: Author: Reference: Purpose:

----------------------------------------------------------------------------------------------*/

SCR Release Header

DECLARE @suser_sname VARCHAR(50)
, @machine VARCHAR(200)
, @sMsg VARCHAR(MAX)
, @sModule VARCHAR(100)
SELECT
@suser_sname = SUSER_SNAME()
, @machine = HOST_NAME()
SET @sMsg = '266 - POS7.2.0.9 - SCR5986'
SET @sModule = 'Link POS'
EXEC Dbo.Lbs_Logmessage @sUser = @suser_sname , @sModule = @sModule , @sMsg = @sMsg , @sStatus = 'Upgrade' , @sMachine = @machine
PRINT @sMsg

Audit Notes:
If you have any queries regarding this support incident, please email admin@linktechnologies.com.au and include the Case No: L12476 in the subject line of all emails regarding this issue.

Document size: 5.9 KB
For call complaints, please contact the Managing Director of the company using this form