View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002457 | SymmetricDS | Bug | public | 2015-11-26 08:47 | 2016-05-24 18:05 |
Reporter | azarubkin | Assigned To | elong | ||
Priority | normal | ||||
Status | closed | Resolution | won't fix | ||
Product Version | 3.6.16 | ||||
Summary | 0002457: Identity value is spoiled after insert to replicated table | ||||
Description | When I insert a record in the table that is synchronized and has Identity column, it is impossible to retrieve the inserted value back, because @@IDENTITY in Microsoft SQL Server returns the last inserted identity value, which is in SYM_DATA table. The insert trigger on the table can be modified to restore old identity value as follows: {{{ -- START OF IDENTITY BACKUP AT THE BEGINNING OF THE TRIGGER DECLARE @BackupIdentitySeederFunc VARCHAR(1000) SET @BackupIdentitySeederFunc = 'DECLARE @BackupIdentity TABLE (IdentityID INT IDENTITY('+CAST(@@IDENTITY AS VARCHAR)+', 1)) INSERT @BackupIdentity DEFAULT VALUES' -- END OF IDENTITY BACKUP -- now we work here, inserting data in various tables -- RETRIEVE ORIGINAL IDENTITY AT THE END OF THE TRIGGER EXEC (@BackupIdentitySeederFunc) PRINT 'Back to Original Identity = '+CAST(@@IDENTITY AS VARCHAR) }}} | ||||
Steps To Reproduce | Insert any record to a replicated table, then SELECT @@IDENTITY | ||||
Tags | No tags attached. | ||||
|
Hi azarubkin, instead of using @@IDENTITY can you try using SCOPE_IDENTITY() and see if that behaves the way you want? |
|
Unfortunately, no. It's Microsoft ADO who issues SELECT @@IDENTITY, and I have no control over that. |
|
Closing as won't fixed. See issue 0002458 for a workaround. |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-11-26 08:47 | azarubkin | New Issue | |
2015-11-26 13:35 | elong | Note Added: 0000733 | |
2015-11-26 15:02 | azarubkin | Note Added: 0000734 | |
2016-05-24 18:04 | elong | Relationship added | related to 0002458 |
2016-05-24 18:05 | elong | Note Added: 0000792 | |
2016-05-24 18:05 | elong | Status | new => closed |
2016-05-24 18:05 | elong | Assigned To | => elong |
2016-05-24 18:05 | elong | Resolution | open => won't fix |