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
 insert increasing nomber into every row

Author  Topic 

ooi_happiness
Starting Member

22 Posts

Posted - 2008-02-27 : 02:33:17
I got a table, and inside column 1, i wish to insert number by increase into every rows untill column 2 has no record, how to do that?

EXPECT OUTPUT EXAMPLE

COLUMN 1 COLUMN 2
-------- --------
10000 ghjgh
10001 asdasd
10002 yhhh
10003 pkoprt
10004 45450
10005 tgtged
10006 retgret
. .
. .
and so on
STOP WHEN NO RECORD

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-27 : 02:41:54
Make column1 identity column or use ROW_NUMBER() function if you are using SQL 2005
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-27 : 03:03:15
If it is just for display at front end, then do numbering there

or if you use SQL Server 2005
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx

Madhivanan

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

- Advertisement -