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 |
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2007-03-30 : 14:22:44
|
I have a proc that inserts data from another database (source) and updates the source db with the identity.I've noticed that occasionally the update hasn't updated the source table even though the inserts before and after the update have run. What kinds of things am I missing?The proc looks like this:Create Proc usp_Proc1 @TableID intAsSet NoCount OnBegin Tran Insert Into DB1.dbo.Table1 (fields) Select (fields) From DB2.dbo.TableA Where TableID = @TableID Set @Chk = @@Error, @Value = Scope_Identity() Insert Into DB2.dbo.History (id, fields) Values (@Value, values) Set @Chk = @Chk + @@Error Update DB2.dbo.TableA Set Field1 = @Value , Field2 = GetDate() Where TableID = @TableID Set @Chk = @Chk + @@Error...More Inserts to DB1.dbo.(Various Tables)...Each Insert has a "Set @Chk = @Chk + @@Error following itIf @Chk = 0 Begin Commit Tran .. EndElse Begin Rollback Tran ..notify End |
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2007-04-02 : 10:14:49
|
quote: is that valid syntax?
No. Thx, Jeff. Sorry, line actually reads:Select @Chk = @@Error, @Value = Scope_Identity() |
 |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2007-04-02 : 11:56:01
|
  duh, nevermind. |
 |
|
|
|
|