SQL Server Cheat Sheet - Ring of Saturn
String Functions
Exact Numerics
Date Functions
Create a Stored Procedure
DATEADD (datepart, number, date)
CREATE PROCEDURE name
bit
decimal
DATEDIFF (datepart, start, end)
tinyint
money
DATENAME (datepart, date)
smallint
numeric
DATEPART (datepart, date)
bigint
@variable AS datatype = value
AS
-- Comments
SELECT * FROM table
DAY (date)
Approximate Numerics
real
float
GETDATE()
Date and Time
MONTH (date)
smalldatetime
timestamp
GO
GETUTCDATE()
Create a Trigger
YEAR (date)
datetime
CREATE TRIGGER name
Strings
ON
Dateparts
text
char
varchar
Unicode Strings
ntext
nchar
nvarchar
Binary Strings
image
binary
varbinary
Miscellaneous
table
Year
yy, yyyy
Quarter
qq, q
Month
mm, m
Day of Year
dy, y
Day
dd, d
Week
wk, ww
Hour
hh
Minute
mi, n
cursor
table
Second
ss, s
sql_variant
xml
Millisecond
ms
FOR
DELETE, INSERT, UPDATE
AS
-- Comments
SELECT * FROM table
GO
Create a View
CREATE VIEW name
AS
Type Conversion
CAST (expression AS datatype)
ABS
LOG10
CONVERT (datatype, expression)
ACOS
PI
ASIN
POWER
ATAN
RADIANS
ATN2
RAND
CEILING
ROUND
COS
SIGN
COT
SIN
DEGREES
SQUARE
Ranking Functions
RANK
NTILE
DENSE_RANK
ROW_NUMBER
Grouping (Aggregate) Functions
MAX
AVG
-- Comments
Mathematical Functions
BINARY_CHECKSUM MIN
SUM
CHECKSUM
EXP
SQRT
FLOOR
TAN
LOG
CREATE UNIQUE INDEX name
ON
table (columns)
Create a Function
CREATE FUNCTION name
(@variable datatype(length))
datatype(length)
STDEV
COUNT
STDEVP
COUNT_BIG
VAR
ASCII
REPLICATE
GROUPING
VARP
CHAR
REVERSE
CHARINDEX
RIGHT
DIFFERENCE
RTRIM
LEFT
SOUNDEX
String Functions
AS
ALTER
DROP
LEN
SPACE
CREATE
TRUNCATE
LOWER
STR
LTRIM
STUFF
NCHAR
SUBSTRING
Available free from
PATINDEX
UNICODE
REPLACE
UPPER
QUOTENAME
Create an Index
RETURNS
CHECKSUM_AVG
Table Functions
SELECT * FROM table
GO
BEGIN
DECLARE @return datatype(length)
SELECT @return = CASE @variable
WHEN 'a' THEN 'return a'
WHEN 'b' THEN 'return b'
ELSE 'return c'
RETURN @return
END
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- how to convert sql from the microsoft sql server database
- microsoft sql server notes for professionals
- sql server cheat sheet ring of saturn
- sql functions
- to char function with dates
- database programming with sql
- you want to create tables with sql because
- mis 120 study guide for exam 2
- report documentation recrystallize
- introduction virginia tech
Related searches
- sql server data classification
- sql server data classification tool
- sql server data types
- azure sql server hyperscale
- sql server 2016 string functions
- sql server connection strings
- sql server localhost connection string
- sample sql server connection string
- sql server trusted connection string
- sql server trusted connection true
- sql server connection string trusted connection
- connection string c sql server examples