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
 SQL Server Development (2000)
 Using the @@identity in DEFAULT constraints

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-21 : 21:39:49
Reginald writes "Sir Guru Master,

We are using MS SQL 7.0 on a WIN NT 4.0 server.

If @@identity is considered a global variable, why does using it in my DEFAULT constraints
always return different values than just selecting it after an insert?

That is, when I use this design for my table:

[MyTable].id int identity(1,1),
[MyTable].tracking_id int DEFAULT(@@identity),

The value inserted into the tracking_id column is usually less than the integer returned from
"select @@identity"

Why are the two numbers different and from where does this discrepency arise?

Humbly,
Reginald the Apprentice"
   

- Advertisement -