Small script to demo the usage of different Identites
Create table testIdentity (Id int Identity Primary Key, name varchar(100))
go
Create Table testIdentityLog (Id int Identity(1000, 1) Primary Key, dt dateTime)
go
Create Trigger trigtestIdentity on testIdentity
after insert
as
Insert into testIdentityLog Values (getdate())
Insert into testIdentity Values ('One')
select @@IDENTITY id, SCOPE_IDENTITY() ActualId
Insert into testIdentityLog Values (getdate())
select @@IDENTITY id, SCOPE_IDENTITY() ActualId, IDENT_CURRENT('testIdentity'), IDENT_CURRENT('testIdentityLog')
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment