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
 General SQL Server Forums
 New to SQL Server Programming
 Select Data

Author  Topic 

yaman
Posting Yak Master

213 Posts

Posted - 2009-05-15 : 06:13:40
Sir i have one column in a table is
Name

When i am fetch Data from table then my result set like this

id Name
1 a
2 b
3 c
with out changing the table definition .

Pls help me out sir .


Yaman

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2009-05-15 : 06:16:00
Yaman, What do you want to do? I don't understand. You want the id to be displayed next to the name is it?

Select ROW_NUMBER() over (order by Name), Name from Table (MSSQL2005)
Go to Top of Page

yaman
Posting Yak Master

213 Posts

Posted - 2009-05-15 : 06:17:51
quote:
Originally posted by EugeneLim11

Yaman, What do you want to do? I don't understand. You want the id to be displayed next to the name is it?





Yes sir

Yaman
Go to Top of Page

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2009-05-15 : 06:23:15
Yaman,

You are using MSSQL2005? This will do the trick ;)

Select ROW_NUMBER() over (order by [Name]), [Name] from Table


check out my blog at http://www.aquariumlore.blogspot.com
Go to Top of Page

yaman
Posting Yak Master

213 Posts

Posted - 2009-05-18 : 08:31:11
quote:
Originally posted by EugeneLim11

Yaman,

You are using MSSQL2005? This will do the trick ;)

Select ROW_NUMBER() over (order by [Name]), [Name] from Table


check out my blog at http://www.aquariumlore.blogspot.com



Thank u so much sir

Yaman
Go to Top of Page
   

- Advertisement -