Friday 21 March 2014

WHERE

SELECT column_name(s)
FROM table_name
WHERE column_name operator value

UPDATE

UPDATE table_name
SET column1=value, column2=value,...
WHERE some_column=some_value

UNION ALL

SELECT column_name(s) FROM table_name1
UNION ALL
SELECT column_name(s) FROM table_name2

UNION

SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2

TRUNCATE TABLE

TRUNCATE TABLE table_name

SELECT TOP

SELECT TOP number|percent column_name(s)
FROM table_name

SELECT INTO

SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_table_name
or
SELECT column_name(s)
INTO new_table_name [IN externaldatabase]
FROM old_table_name