Skip to content

Instantly share code, notes, and snippets.

@StuffbyYuki
Created December 10, 2021 19:26
Show Gist options
  • Select an option

  • Save StuffbyYuki/fa73ecee2afba4e8ca6f95f1b5f63c45 to your computer and use it in GitHub Desktop.

Select an option

Save StuffbyYuki/fa73ecee2afba4e8ca6f95f1b5f63c45 to your computer and use it in GitHub Desktop.
SQL server - get tables/views based on column names
// change .views to .tables for tables
SELECT
sys.columns.name AS ColumnName,
views.name AS TableName
FROM
sys.columns
JOIN sys.views ON
sys.columns.object_id = views.object_id
WHERE
sys.columns.name = 'YOUR_COLUMN';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment