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)
 Triger insert number into ID field

Author  Topic 

tedew
Starting Member

22 Posts

Posted - 2005-09-30 : 05:22:03
hello,

I have a porblem with Trigger which inserting numbers into ID Column.
Something like autonumeric in Access .
Is it posibble ??

bye,
sorry for my english

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-30 : 05:29:31
In SQL Server you can set the Identity property to true when creating the table in Enterprise Manager or using this query

Create table yourTable(id int identity,........)

I think you dont need trigger for this


Madhivanan

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

tedew
Starting Member

22 Posts

Posted - 2005-09-30 : 06:52:04
hello,
@madhivanan thanks for help :) it's working fine
I have one more question, is it possible reset identity value ??

bye.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-30 : 06:59:20
If you dont want the data at all, then truncate it (All data will be deleted and identity reset)

Truncate Table yourTable

If you want to keep all the existing records, then

DBCC CHECKIDENT (yourTable, RESEED, 0)


Madhivanan

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

- Advertisement -