Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

how to distinguish two row in sql server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
chenhong - 13 Aug 2007 09:45 GMT
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
Mark Rae [MVP] - 13 Aug 2007 10:22 GMT
>a query return with some identical rows,
> how can I distinguish them?
[quoted text clipped - 4 lines]
>
> TIA

select DISTINCT rowid, column1, column2 from mytable

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Ladislav Mrnka - 13 Aug 2007 10:30 GMT
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

> a query return with some identical rows,
> how can I distinguish them?
[quoted text clipped - 4 lines]
>
> TIA

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.