Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Finding unique field names with different values

Author  Topic 

alpoor
Starting Member

29 Posts

Posted - 2005-06-08 : 21:50:00
I am in a situation where I need to find out unique field names with different values in a table having 200+ columns.

Let's say I have two rows with 200+ columns ( I exported these rows from Lotus Notes to SQL Server) I am not sure what columns makes unique of these rows. It's going to be tedious by checking each column values.

Is there anyway I can write a squl query on these two rows which outputs column names which are having unique values.

I would appreciate If anybody gives me hint about achieving desired result

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-06-08 : 22:08:36
How many rows are in this table? What do you mean "what columns makes unique of these rows"? Are you wanting to know what the DISTINCT list of values is for each column??? Give us a data example, so we can make since of what you're trying to say.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

mpetanovitch
Yak Posting Veteran

52 Posts

Posted - 2005-06-09 : 18:59:51
Do you mean, is there combination of columns that can be used to unqiuely identify everyrow.

You can do a select distinct * and compare the rows returned to a select count(*), if not the same then you have bigger problems.

If they are the same then:
IE
select count(DISTINCT col1, col2, col2) from table1
select count(*) from table1

if they are equal then you are set...
however with 200 columns there are alot of combinations to try. Hopefully it will be obvious which one to try first. IE if you had a naturally unqiue key, like SSN. That would be a good starting place.

Mike Petanovitch
Go to Top of Page
   

- Advertisement -