?
Solved

Get table names that dont have a primary key set

Posted on 2005-04-21
3
Medium Priority
?
182 Views
Last Modified: 2010-03-19
title says it all...


I want to get a list of all the tables within a specific database that do not have a primary key set.


many thanks in adv.

Phil
0
Comment
Question by:detox1978
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
obahat earned 1000 total points
ID: 13835745
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND OBJECTPROPERTY(object_id(TABLE_NAME), 'TableHasPrimaryKey ') = 0
0
 
LVL 2

Author Comment

by:detox1978
ID: 13835798
thanks again obahat,

2nd question in 10mins you've answered correctly.


0
 
LVL 5

Expert Comment

by:obahat
ID: 13835821
LOL. I didn't know this was a test... :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question