SQL Server Performance Forum – Threads Archive
Unique recordsHello, 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
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!
.. for information. Satya SKJ
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=’‘ />)].<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 />