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
 Transact-SQL (2000)
 distinct count

Author  Topic 

thebruins
Starting Member

31 Posts

Posted - 2005-10-21 : 10:03:03
I have to do some work on a DB, and for a certain table I want to do a distinct count on a column, but the problem is that the column's type is uniqueidentifier. mssql refuses to do a distinct count on that datatype.

1. Why?
2. Is there another way to do a distinct count on that column, without having to alter the table?

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-21 : 10:07:44
Cast it into varchar type

select count(distinct cast(col as varchar(36))) from yourTable


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

thebruins
Starting Member

31 Posts

Posted - 2005-10-21 : 10:16:58
thanks!
Go to Top of Page
   

- Advertisement -