Quantcast
Channel: DotNetBlocks - SQL
Viewing all articles
Browse latest Browse all 13

Sql Identity Retrieval - Alternative Methods

$
0
0

Has anyone ever had an issue returning a value for @@Identity? If so, here is one work around that you can try.

Basic Insert Statement:

-- Run Me
INSERT INTO dbo.tbl_X (Storename)  VALUES( 'test qae3')

-- Use this instead of @@Identity. 
select SCOPE_IDENTITY()
select IDENT_CURRENT('dbo.tbl_X') AS NewID


Viewing all articles
Browse latest Browse all 13

Trending Articles