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 2005 Forums
 Transact-SQL (2005)
 prtial distinct

Author  Topic 

amitbarkai
Starting Member

19 Posts

Posted - 2010-03-09 : 04:56:34
Hey All
this is a small part of my query
SELECT DISTINCT ON (S.ID) AS StationID,
ST.Value AS StationTypeName,
R.ID AS RegionID,
R.Value AS Region,
A.ID AS AlertID,
A.CreationDate,
A.XMLDATA, <== problematic xml field
A.LastUpdateDate,...

doing so gives me the error
The xml data type cannot be selected as DISTINCT because it is not comparable.

which seems reasonable ,xml filed cannot be comapared

does anyone knows away to skip a field while using Distinct

note
* the xml is a mandatory and cannot be removed
* for historical reasons we are using the xml field
* i tried to convert the xml to nvarchar(max) and it works
but i want to know if there's another way

thanks

Amit

amitbarkai
Starting Member

19 Posts

Posted - 2010-03-09 : 06:15:18
i guessing i need to be more clear about my question :)
let say your query return 2 field
ID Name ( the query doesn't matter for now )
1 AAA
1 AAA
1 BBB
1 DDD
if we use distinct on the ID field the query will return

1 AAA
1 BBB
1 CCC
the distinct will remove a dupplication of rows
meaning it will comare the other fields as well

while one of the returned fields is an xml the distinct will not be possible
what i want to know if there a way to tell the sql server to skip
on a specfic file (the xml field)
Go to Top of Page
   

- Advertisement -