SQL Server: Functions Cheat Sheet

String Functions

  • ASCII
  • CHAR
  • CHARINDEX
  • DIFFERENCE
  • LEFT
  • LEN
  • LOWER
  • LTRIM
  • NCHAR
  • PATINDEX
  • REPLACE
  • QUOTENAME
  • REPLICATE
  • REVERSE
  • RIGHT
  • RTRIM
  • SOUNDEX
  • SPACE
  • STR
  • STUFF
  • SUBSTRING
  • UNICODE
  • UPPER

Exact Numerics

  • bit
  • tinyint
  • smallint
  • bigint

Approximate Numerics

  • float

Date and Time

  • smalldatetime
  • datetime
  • Strings
  • char
  • varchar

Unicode Strings

  • nchar
  • nvarchar

Binary Strings

  • binary
  • varbinary

Miscellaneous

  • cursor
  • sql_variant
  • decimal
  • money
  • numeric
  • real
  • timestamp
  • text
  • ntext
  • image
  • table
  • xml

Date Functions

  • DATEADD (datepart, number, date)
  • DATEDIFF (datepart, start, end)
  • DATENAME (datepart, date)
  • DATEPART (datepart, date)
  • DAY (date)
  • GETDATE()
  • GETUTCDATE()
  • MONTH (date)
  • YEAR (date)

Dateparts

Yearyy, yyyy
Quarterqq, q
Monthmm, m
Day of Yeardy, y
Daydd, d
Weekwk, ww
Hourhh
Minutemi, n
Secondss, s
Millisecondms

Type Conversion

  • CAST (expression AS datatype)
  • CONVERT (datatype, expression)

Ranking Functions

  • RANK
  • DENSE_RANK
  • NTILE
  • ROW_NUMBER

Grouping (Aggregate) Functions

  • AVG
  • BINARY_CHECKSUM
  • CHECKSUM
  • CHECKSUM_AVG
  • COUNT
  • COUNT_BIG
  • GROUPING
  • MAX
  • MIN
  • SUM
  • STDEV
  • STDEVP
  • VAR
  • VARP

Table Functions

  • ALTER
  • CREATE
  • DROP
  • TRUNCATE

Mathematical Functions

  • ABS
  • ACOS
  • ASIN
  • ATAN
  • ATN2
  • CEILING
  • COS
  • COT
  • DEGREES
  • EXP
  • FLOOR
  • LOG
  • LOG10
  • PI
  • POWER
  • RADIANS
  • RAND
  • ROUND
  • SIGN
  • SIN
  • SQUARE
  • SQRT
  • TAN

Leave a Reply

Your email address will not be published. Required fields are marked *