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 |
|
ann
Posting Yak Master
220 Posts |
Posted - 2006-07-08 : 09:09:35
|
| How do you return a value from your sp when you don't find a match? I am doing insert with a where clause, but I want to know if there is no match on it? Can this be done simply? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-08 : 09:13:14
|
you can use @@rowcount inside your SP to check and return a value via the OUTPUT parameter. KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-07-10 : 02:55:13
|
| or can you post the code you used? What do you mean by no matches in insert statement?MadhivananFailing to plan is Planning to fail |
 |
|
|
ann
Posting Yak Master
220 Posts |
Posted - 2006-07-10 : 08:58:38
|
| I want to know when something doesn't get inserted - I have to let the user know so they can do something else with the data:ALTER PROCEDURE UpdateSatisfied@NoteID int,@CreateDate datetime,@NoteAuthor VARCHAR(20),@CaseNote CHAR(12),@fraudCaseID intASBEGIN TRAN UPDATE SatisfyNotes SET NoteAuthor = @NoteAuthor ,CreateDate = @CreateDate ,CaseNote = @CaseNote WHERE CaseNotes.NoteID = @NoteID IF (@@ERROR <> 0) GOTO ERR_HANDLER INSERT INTO CaseNotes(NoteStatus) VALUES ('Satisfied') WHERE CaseNotes.NoteID = @NoteID IF (@@ERROR <> 0) GOTO ERR_HANDLER COMMIT TRANRETURN 0ERR_HANDLER:ROLLBACK TRANRETURN 1 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-07-10 : 09:01:35
|
| Do you need UPSERT? (Update when matched records;Insert if new)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|