3.6.08

T-SQL to fetch the tables with out primary key in the database

Today, i've tried to fetch table details from sysobjects. I have started digging this table to retrieve the table information about primary key checking, foreign key and other constraints details and arrived with a small code snippet to retrieve the tables which doesn't have primary key.
Code Snippet to retrieve the table without primary key
select name as TableWithoutPrimaryKey
from sys.sysobjects
where type='U'
and objectproperty(id,'TableHasPrimaryKey') = 0

I've used Object property to fetch this information.

Happy Learning!!!

Regards,

Venkatesan prabu. J

2 comments:

  1. hi iam saroj.
    i am a sql dba in Nuware. but not done my certification. can you please help for this . can you told me where you appear this exam.
    and what are the guidence i follow for this MCITP exam. i am totally new to this field.
    saroj.das@nuware.com.
    09986195862

    ReplyDelete
  2. Sorry for the delayed reply. You can check microsoft websites for the areas to be covered for MCITP. You can opt some prometric testing center to write the exams.

    For writing MCITP, you have to clear MCTS on SQL server 2005.. prefer SQL Server 2008.

    Wishing you all the best.
    Regards,
    Venkatesan prabu .J

    ReplyDelete