SQL Cheat Sheet

Date Conversion

Format #

Query

Sample

1

select convert(varchar, getdate(), 1)

12/30/06

2

select convert(varchar, getdate(), 2)

06.12.30

3

select convert(varchar, getdate(), 3)

30/12/06

4

select convert(varchar, getdate(), 4)

30.12.06

5

select convert(varchar, getdate(), 5)

30-12-06

6

select convert(varchar, getdate(), 6)

30 Dec 06

7

select convert(varchar, getdate(), 7)

Dec 30, 06

10

select convert(varchar, getdate(), 10)

12-30-06

11

select convert(varchar, getdate(), 11)

06/12/30

12

select convert(varchar, getdate(), 12)

061230

23

select convert(varchar, getdate(), 23)

2006-12-30

101

select convert(varchar, getdate(), 101)

12/30/2006

102

select convert(varchar, getdate(), 102)

2006.12.30

103

select convert(varchar, getdate(), 103)

30/12/2006

104

select convert(varchar, getdate(), 104)

30.12.2006

105

select convert(varchar, getdate(), 105)

30-12-2006

106

select convert(varchar, getdate(), 106)

30 Dec 2006

107

select convert(varchar, getdate(), 107)

Dec 30, 2006

110

select convert(varchar, getdate(), 110)

12-30-2006

111

select convert(varchar, getdate(), 111)

2006/12/30

112

select convert(varchar, getdate(), 112)

20061230

Strip Non-Alphabetic Characters

To strip all non-alphabetic characters from string in SQL Server

Create a scalar function

Sample Usage

Validate UEN

A custom scalar function created by myself to validate for Unique Entity Number (UEN). *PS Feel free to contribute for the UEN validate function if there is any missing validation rules.

Sample Usage

Reference

Validate SG NRIC

Scalar function to validate Singapore Identification Number / FIN Number.

Sample Usage

Last updated

Was this helpful?