Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. select t.name as table_name, c.name as column_name from sys.columns c
  2. inner join sys.tables t on t.object_id = c.object_id
  3. left join sys.foreign_key_columns f on
  4. (f.parent_object_id = c.object_id and f.parent_column_id = c.column_id) or
  5. (f.referenced_object_id = c.object_id and f.referenced_column_id = c.column_id)
  6. where c.name like '%id' and f.constraint_column_id is null and c.column_id > 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement