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.
| Author |
Topic |
|
stephensutherland
Starting Member
4 Posts |
Posted - 2002-08-21 : 18:10:18
|
| strSQL = "Set Nocount on "strSQL = strSQL + " Insert Table1 (TopicName, SortOrder) VALUES ('X', -1) "strSQL = strSQL + " select IdentityInsert=@@identity"strSQL = strSQL + " set nocount off"Set objRS = objConn.Execute(strSQL)insert into table2 (intField) Values ( objRS("IdentityInsert") the value inserted in table2 ends up being 13 when the real number should have been 77. The reason is because there is another insert trigger on Table1.Is this a behavior that I simply have to live with ? Stev |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-08-21 : 18:13:16
|
| Try SELECT IdentityInsert = SCOPE_IDENTITY() instead of @@IDENTITY.Here's an article with more info: [url]http://www.sqlteam.com/item.asp?ItemID=319[/url]EDIT: I think SCOPE_IDENTITY only exists in SQL 2000...Edited by - ajarnmark on 08/21/2002 18:16:07 |
 |
|
|
|
|
|