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.
| Author |
Topic |
|
Josie
Starting Member
1 Post |
Posted - 2009-01-09 : 05:51:42
|
| MorningI want to add an ID field to an existing table, but I want to add it with the records in a particular order, cos I want to use the ID in queries grouping the records what do I need to add to: alter table performance add ID int identity(1,1) to make sure the ID is added like so: order by specialty asc, activity descthanks |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-01-09 : 05:54:15
|
| Hi,Just add an identity column as u specified above and While retreiving get the records as order by specialty asc, activity desc. |
 |
|
|
revelator
Starting Member
32 Posts |
Posted - 2009-01-09 : 06:23:42
|
| What is your intended purpose of the ID column? The order should make no difference.Waiting for the Great Leap Forwards |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-09 : 06:28:56
|
| try like this select identity(int,1,1)as id ,* into #temp from performance order by specialty asc,activity descselect * from #temp |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-09 : 06:31:14
|
seems like what you're asking isalter table performance add ID int nullUPDATE tSET ID=SeqFROM(SELECT ID,ROW_NUMBER() OVER (order by specialty asc, activity desc) AS SeqFROM performance)t |
 |
|
|
|
|
|