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 2008 Forums
 Transact-SQL (2008)
 is there a way to find teh unique combination of

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2013-02-13 : 17:08:37
Is there a way to find teh unique combination of columns based on table data:
i have the following table with 260k rows, now i want to see the best combination of columns which make the row unique.
is it possible?

I have loaded the data from another system now want to see
CREATE TABLE [dbo].[LAW_DEL_IMGNOW_GLACCT_FIRST](
[TABLE_NAME] [varchar](50) NULL,
[ACTIVE] [varchar](1) NULL,
[BUSINESSUNITID] [int] NULL,
[COST_CENTER] [int] NULL,
[GLACCT] [int] NULL,
[GLSUBACCT] [int] NULL,
[GLACCTDESC] [varchar](250) NULL,
[GLACCT5] [varchar](250) NULL,
[GLACCT6] [varchar](250) NULL) ON [PRIMARY]

Thanks a lot for the helpful info.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-13 : 23:38:59
for that you need to take each set of columns you think would make a unique combination and do like

SELECT COL1,COL2,COL3
FROM table
GROUP BY Col1,Col2,Col3
HAVING COUNT(*) >1


if this returns any result then it means combination has duplicates

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2013-02-14 : 08:25:58
Thanks Visakh
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-14 : 10:04:46
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -