Solved

Autoincrement field in MS SQL 2005 select

Posted on 2014-02-26
2
744 Views
Last Modified: 2014-02-26
Hi,

 I have a query:  select Name from T1;

  I am trying to achieve this:

Name Order
Apple 1
Banana 2
Allison 3

in other words an autoincremented number in the second column...how can I do this?
0
Comment
Question by:LuckyLucks
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 39890332
select Name, rn = row_number() over ( order by Name) from T1;
0
 

Expert Comment

by:bharathmosur
ID: 39890408
I did not understand it completely, But you can always create a temporary table. It goes in this way.

Select Name, Order = Identity(Int,1,1) Into ##temp From T1.

Select * From ##Temp
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now