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)
 Insert column as unique counting number

Author  Topic 

hvdtol
Yak Posting Veteran

50 Posts

Posted - 2002-08-07 : 08:56:05
I need to insert row in a table, adding a unique number into a column.
But i do not know how i write in T-sql.
Is somebody able to help me on this ?

Thanks in advance


-----
DECLARE @rec_count int

INSERT INTO table ( field1
--- >>> field1 is the unique number, defined as 'int' <<<

, field2
, field3)

SELECT
(set @rec_count = @rec_count + 1 )

---(or something like this but i know this does not work)
, in_field2
, in_field3

FROM table_in



Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-08-07 : 09:00:21
Have you considered using the IDENTITY property on field1?

Jay White
{0}
Go to Top of Page

hvdtol
Yak Posting Veteran

50 Posts

Posted - 2002-08-07 : 15:28:13
No i haven't, but i think this is what i need.

Go to Top of Page
   

- Advertisement -