Some Important Functions In SQL

Hello Guys,
Merry Christmas to all of you,
Here is one day asked me some special question, what are the special functions we use it in our daily life?
I answered him, it is as per your uses, here are few which we normally use in our daily life...

SELECT * FROM TableName
--SUBSTRING
--SELECT SUBSTRING(ColumnName,StartIndex,CharacterNo) FROM TableName
SELECT SUBSTRING(Address2,1,len(Address2)-3) FROM TableName
--DateAdd
--SELECT DateAdd(DatePart,Interval,DateParameter)
SELECT DateAdd(MM,1,GetDate()) --It will add month (with 1 )
--DateDiff
--SELECT DateDiff(DatePart,StartDate,EndDate) AS [Date Difference]
SELECT DateDiff(dd,GetDate(),GetDate()+5) AS [Date Difference]
--DateName
SELECT DateName(MM,GetDate()) --It will display month Name
--Month Number
SELECT Month(GetDate()) --It will display month Name
--DatePart
SELECT DatePart(YYYY,GetDate()) AS [Current Year] --It will display month Name
--LEFT Character from string
SELECT LEFT(Address2,2) as LeftChar FROM TableName
--RIGHT Character from string
SELECT RIGHT(Address2,2) as RightChar FROM TableName

Comments