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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-01-31 : 08:44:12
|
| Fardin writes "/*I use the following trigger to update the inserted record with a sequence number that I call from stored procedureThe Trigger works when you add one record at a time but when I use query to insert many records, the subquery gives me the following errorSubquery returned more than one value. This is not permitted when subquery follows =,!= .....*/CREATE TRIGGER [Insert_New_Sequence] ON Table1FOR INSERTASDeclare @REC_NO intselect @REC_NO=INVTRANS_RECNO from insertedif @REC_NO is NULLBeginDeclare @SEQ_ID intexec Get_Next_Sequence 'Table1' ,@SEQ_ID outputUpdate Table1 set RECNO=@SEQ_ID Where ID = (Select ID from Inserted)End" |
|
|
ToddV
Posting Yak Master
218 Posts |
Posted - 2002-01-31 : 09:02:36
|
| Change this: Update Table1 set RECNO=@SEQ_ID Where ID = (Select ID from Inserted)TO ThisUpdate Table1 set RECNO=@SEQ_ID FROM Table1 A JOIN INserted B ON A.ID = B.IDThis will be able to handle more than one row inserts. |
 |
|
|
|
|
|