SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 is there a way to find teh unique combination of
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

536 Posts

Posted - 02/13/2013 :  17:08:37  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 02/13/2013 :  23:38:59  Show Profile  Reply with Quote
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

536 Posts

Posted - 02/14/2013 :  08:25:58  Show Profile  Reply with Quote
Thanks Visakh
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/14/2013 :  10:04:46  Show Profile  Reply with Quote
welcome

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000