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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 increment ID in table

Author  Topic 

silver_atlima
Starting Member

4 Posts

Posted - 2004-11-01 : 07:56:33
Hi,

A fairly silly question but I have no idea how to do this in code.

I have this one columned table that only holds sequential numbers.(1,2,3,4,5, etc). I want to populate this table through SQL code and not manually enter all these values in the table.

Can anyone help me write this sql query?

Thanks!!

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-11-01 : 08:21:55
If this number field is set to identity and to increment.
you don't need t oinsert the number, it will automatically insert the new record giving it the next number.
Go to Top of Page

tran008
Starting Member

38 Posts

Posted - 2004-11-01 : 08:23:32
look up Identity in BOL
Go to Top of Page

silver_atlima
Starting Member

4 Posts

Posted - 2004-11-01 : 09:01:14
Thanks but I don't need this column to be an identity column. Thanks for the posts. :) I did this:

DECLARE @x int
SET @x = 1

WHILE @x < 1001
BEGIN
INSERT INTO tempTbl(NUM) VALUES (@x)
set @x = @x + 1
END
Go to Top of Page
   

- Advertisement -