Skip to content

Instantly share code, notes, and snippets.

@loonison123
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save loonison123/e37ceb591fab4e54b3d6 to your computer and use it in GitHub Desktop.

Select an option

Save loonison123/e37ceb591fab4e54b3d6 to your computer and use it in GitHub Desktop.
Common Sql Snippets
-- Update statement with join
UPDATE Table1
SET Table1.LastName = 'DR. XXXXXX'
FROM Table1 T1, Table2 T2
WHERE T1.id = T2.id
and T1.id = '010008'
-- Alter column on existing table
ALTER TABLE {TABLENAME}
ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL}
CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}
-- Multiple CASE statement
CASE WHEN refnumber = '223' then 'true'
WHEN notes = 'denied' then 'false'
ELSE null as 'ColumnTitle'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment