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.
Author |
Topic |
NguyenL71
Posting Yak Master
228 Posts |
Posted - 2013-10-22 : 12:05:15
|
I have a table with a lot of dup values and I need to select DISTINCT values from this table and put into temp and delete records in the original table and re-insert distinct values from temp into this table but getting an error because it has XML datatype in one of the column, the table is CDC and has not PK. How can I get around this?. Is there an other way to get distinct values from the table?. SQL 2012. I appreciate your help./****** Object: Table [HIX].[dbo_PMPMRate_CT] Script Date: 10/22/2013 8:44:28 AM ******/SET ANSI_NULLS ONCREATE TABLE [abc].[dbo_TestRate_CT]( [__$start_lsn] [binary](10) NOT NULL, [__$seqval] [binary](10) NOT NULL, [__$operation] [int] NOT NULL, [__$update_mask] [varbinary](128) NOT NULL, [PMPMRate_ID] [int] NULL, [Entity_ID] [bigint] NULL, [CreateDate] [datetime] NULL, [UpdateDate] [datetime] NULL, [PlanCatelogSettings] [xml] NULL, [Effective_date] [datetime] NOT NULL) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]GOSELECT DISTINCT * FROM abc.dbo_TestRate_CT;GO-- Error:Msg 421, Level 16, State 1, Line 1The xml data type cannot be selected as DISTINCT because it is not comparable. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-10-22 : 13:04:04
|
Couple of thoughts come to mind, but none of them perfect:1. If you don't care about the distinctness of the XML column, exclude that column from your distinct clause.2. Cast the XML column as varchar(max) and then look for distinctness. However, this is not safe because logically identical XML fragments may not produce identical strings when you cast.3. Shred the XML column into relational data and put that together with the other columns and look for distinctness. |
|
|
|
|
|
|
|