How to add an index column whose values you can retrieve

Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2009
Posts: 4
Reputation: Smirgu is an unknown quantity at this point 
Solved Threads: 0
Smirgu Smirgu is offline Offline
Newbie Poster

How to add an index column whose values you can retrieve

 
0
  #1
Aug 5th, 2009
I would like to add a column to an existing table, where the new column would only have running numbers starting from 1. If I've understood correctly, the "create index" command is not the right way to do this, as that's attached to just certain columns to speed up querying.

The reason why I want this is that after exporting the data from the database I would still need to know the order of the rows.
Last edited by Smirgu; Aug 5th, 2009 at 6:27 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,214
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: How to add an index column whose values you can retrieve

 
0
  #2
Aug 5th, 2009
  1. CREATE TABLE TestTable
  2. (
  3. SomeInt INT,
  4. SomeString VARCHAR(10)
  5. )
  6.  
  7. GO
  8. --This adds an auto number column
  9. ALTER TABLE TestTable Add RowNumber INT identity(1, 1)
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 4
Reputation: Smirgu is an unknown quantity at this point 
Solved Threads: 0
Smirgu Smirgu is offline Offline
Newbie Poster

Re: How to add an index column whose values you can retrieve

 
0
  #3
Aug 5th, 2009
Originally Posted by sknake View Post
  1. CREATE TABLE TestTable
  2. (
  3. SomeInt INT,
  4. SomeString VARCHAR(10)
  5. )
  6.  
  7. GO
  8. --This adds an auto number column
  9. ALTER TABLE TestTable Add RowNumber INT identity(1, 1)
Thanks! That did the trick!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,214
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: How to add an index column whose values you can retrieve

 
0
  #4
Aug 5th, 2009
You're welcome.

Please mark this thread as solved an good luck!
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC