Skip to content

Instantly share code, notes, and snippets.

@PRElias
Created April 11, 2019 14:35
Show Gist options
  • Save PRElias/70fbf4ad79e625eba75b462d7e046bce to your computer and use it in GitHub Desktop.
Save PRElias/70fbf4ad79e625eba75b462d7e046bce to your computer and use it in GitHub Desktop.
SQL Server all fields
SELECT SchemaName = c.table_schema,
TableName = c.table_name,
ColumnName = c.column_name,
DataType = data_type,
Validate = 'SELECT TOP 1 ' + c.column_name + ' FROM ' + c.table_name
FROM information_schema.columns c
INNER JOIN information_schema.tables t
ON c.table_name = t.table_name
AND c.table_schema = t.table_schema
AND t.table_type = 'BASE TABLE'
where c.column_name like '%tel%'
ORDER BY SchemaName, TableName, ordinal_position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment