how to distinguish two row in sql server

  • Thread starter Thread starter chenhong
  • Start date Start date
C

chenhong

a query return with some identical rows,
how can I distinguish them?

what I want is like this:

select rowid, column1, column2 from mytable

TIA
 
a query return with some identical rows,
how can I distinguish them?

what I want is like this:

select rowid, column1, column2 from mytable

TIA

select DISTINCT rowid, column1, column2 from mytable
 
Hi,
if you would like to distinguish between two identical rows you have to
change your query to use some row numbering. SQL 2005 provides you mechanism
to do that:

select
NumberedTable.*
from
(
select
column1, column2,
ROW_NUMBER() over (order by column1, column2) as RowNum
from myTable
) NumberedTable

If you do not use SQL 2005 you have to create temporary table with one more
identity column and first fill this table with your date and after that
select that data from this table.

There is still question if your identical rows will always be in same order
but who knows? :)

Regards,
Ladislav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top