Login or Sign Up to become a member!
LessThanDot Site Logo

LessThanDot

A Technical Community for IT Professionals

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Highly Rated Users

Forum
No Posts Rated

Top 50
Given
Received

Forum Statistics

Users
Members:
1875
Members Online:
3
Guests Online:
84

Total Post History
Posts:
81446
Topics:
18714

7-Day Post History
New Posts:
0
New Topics:
0
Active Topics:
0

Our newest member
konam534As

Other

FAQ
All times are UTC [ DST ]

Google Ads

Non-existent tables identified as "without a primary key"

Please wait...

Non-existent tables identified as "without a primary key"

Postby SAinCA on Fri Jan 20, 2012 10:40 pm

The user 'swdev' exists in the database.

There is no schema for the user 'swdev'.

There are no tables for the schema/user in the SSMS Object Explorer.

But SQLCop shows 44 tables named swdev.<tablename>

Appears to be a bug... :(

What could I be missing, please?
User avatar
SAinCA
Newbie
Newbie
LTD Bronze - Rating: 3
 
Posts: 4
Joined: Fri Jan 20, 2012 7:45 pm
Location: Yorba Linda, CA. USA
Unrated

Re: Non-existent tables identified as "without a primary key"

Postby gmmastros on Fri Jan 20, 2012 11:07 pm

I agree. This appears to be a bug.

Can you please run the following query and then let me know if it returns the correct information? If it does, I will update SQLCop accordingly.

  1. SELECT  su.name + '.' + AllTables.Name As ProblemItem
  2. FROM    (
  3.         SELECT  Name, id, uid
  4.         From    sysobjects
  5.         WHERE   xtype = 'U'
  6.         ) AS AllTables
  7.         INNER JOIN sys.Schemas su
  8.             On AllTables.uid = su.schema_id
  9.         LEFT JOIN (
  10.             SELECT parent_obj
  11.             From sysobjects
  12.             WHERE  xtype = 'PK'
  13.             ) AS PrimaryKeys
  14.             ON AllTables.id = PrimaryKeys.parent_obj
  15. WHERE   PrimaryKeys.parent_obj Is Null
  16. ORDER BY su.name,AllTables.Name
  17.  
-George
User avatar
gmmastros
LTD Admin
LTD Admin
LTD Gold - Rating: 1630LTD Gold - Rating: 1630LTD Gold - Rating: 1630LTD Gold - Rating: 1630LTD Gold - Rating: 1630
LTD Gold - Rating: 1630LTD Gold - Rating: 1630LTD Gold - Rating: 1630LTD Gold - Rating: 1630LTD Gold - Rating: 1630
LTD Gold - Rating: 1630LTD Gold - Rating: 1630
 
Posts: 2367
Joined: Tue Oct 09, 2007 5:19 pm
Unrated

Re: Non-existent tables identified as "without a primary key"

Postby SAinCA on Sat Jan 21, 2012 1:47 am

All the swdev.% tables have disappeared from the list and it appears that the remaining tables listed are the correct ones (we don't bother with PKs on audit tables as we so very, very rarely reference them.)

Thanks for the query, George. Glad to see my DB isn't corrupt.
User avatar
SAinCA
Newbie
Newbie
LTD Bronze - Rating: 3
 
Posts: 4
Joined: Fri Jan 20, 2012 7:45 pm
Location: Yorba Linda, CA. USA
Unrated