Skip to content

Instantly share code, notes, and snippets.

@deangrant
Created April 25, 2023 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deangrant/51aa6f8839dc6602dd7ff55ed8c78fd5 to your computer and use it in GitHub Desktop.
Save deangrant/51aa6f8839dc6602dd7ff55ed8c78fd5 to your computer and use it in GitHub Desktop.
Provides example of conditional update in SQL if column value is specified
UPDATE {{ table_name }}
SET {{ column_name }} CASE WHEN {{ value}} IS NOT NULL THEN {{ value }} ELSE {{column_name }} END
WHERE {{ column_name }} = {{ value }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment