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
 Add count rows to already existent table

Author  Topic 

VeselaApo
Posting Yak Master

114 Posts

Posted - 2011-01-19 : 13:38:43
Hi,

I have this table with some information and 20 rows. I added a new column that is called Rowcount and I want to populate this column with all the row counts from 1 to 20 so that each entry in the table will have a unique identified (a number from 1 to 20).
I tried doing this through loop and update statement but it doesnt work properly. Can someone advise on the easiest way to do this?

thanks

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-01-19 : 14:53:11
ALTER TABLE yourTable ADD id INT IDENTITY(1, 1) NOT NULL;
Go to Top of Page

VeselaApo
Posting Yak Master

114 Posts

Posted - 2011-01-19 : 14:56:38
thanks worked! can you pls remind me how do i mark this thread as answered?
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-01-19 : 14:59:53
Haha, I have no idea how to do that.

Glad it worked for you though.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-20 : 10:06:47
quote:
Originally posted by VeselaApo

thanks worked! can you pls remind me how do i mark this thread as answered?


Only option is to edit the subject and add SOLVED at the end

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -