Created
January 21, 2019 08:52
-
-
Save joe-oli/3a7239bf2583610279f61f016fc61852 to your computer and use it in GitHub Desktop.
sql server random notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Find tables without primary keys (PKs) in SQL Server database | |
select schema_name(tab.schema_id) as [schema_name], | |
tab.[name] as table_name | |
from sys.tables tab | |
left outer join sys.indexes pk | |
on tab.object_id = pk.object_id | |
and pk.is_primary_key = 1 | |
where pk.object_id is null | |
order by schema_name(tab.schema_id), | |
tab.[name] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment