Basics
Batch Separators
Batch Separators combine one or more SQL statements that are sent to the engine as one set of statements.
Any variable declared in the current batch will not be visible in the next batch.
Variables
Functions
String Functions
SUBSTRING()
REPLACE()
Mathematical Functions
ROUND()
CIEL()
Date Functions
ISDATE()
validates date and time
GETDATE()
return current date and time
DATEFROMPARTS()
requires year, month and day
DATETIMEFROMPARTS()
requires year, month, day along with hour, minute, second, millisecond
DATEADD()
can add/subract to/from date and time
EOMONTH()
returns the last date of the specified month
EOMONTH(GETDATE())
DATEDIFF()
returns the difference between the specified dates
SELECT DATENAME(MONTH, GETDATE())
SELECT DATEPART(MONTH, GETDATE())
Output
February (Name of the Month)
Output
2 (Numerical representation of the month)
Window Functions
Value Window Functions
FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD()
MERGE
MERGE
Last updated
Was this helpful?