Unique records | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Unique records

Hello, everybody. I have a database with a set of tables without primary, foregn keys being set up.
How can I verify the combination of values that uniquely indentify the records.
Looks like for some of the tables a primary key should be combination of at least three records. How do I check what combination of values would uniquely indentify records???? Thanks.
What information are stored in tables?
Can you reach designer and ask what kind of information are stored?
Or you only need a script to find unique values? Luis Martin
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.
Just by looking at the data may not give you an accurate picture of a candidate key.
Maybe you add a PK now, but infact it is possible the table can hold records with identical values for those fields but with some other field differing. You need to understand the business logic built into the schema. May mean trawling through the source code of apps using it, lots of fun to be had there!
http://www.sql-server-performance.com/gv_index_data_structures.asp
http://www.sql-server-performance.com/glossary.asp
.. for information. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
Thanks for your help. I would like to find how many different combinations of three values I have in the table.
Can you help me? Thanks.
select field1, field2, field3, count(*) from MyTable group by field1, field2, field3
3!*rows[<img src=’/community/emoticons/emotion-3.gif’ alt=’:eek:‘ />)].<br /><br /><br />Luis Martin<br />Moderator<br />SQL-Server-Performance.com<br /><br /><font size="1">All postings are provided “AS IS” with no warranties for accuracy.</font id="size1"><br /><br />
]]>