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 |
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2009-08-28 : 02:58:05
|
| Hi all,i made an update to a table (Healthhistory) and i have attached a trigger for this table.what i want to know is if i update table which has no matching recordslike update healthhistoryset historyname = 'test'where historyid=-1 [there is no record having primary key "histortid as -1)in trigger i have checked like thisif notexists(select 1 from deleted)if notexists(select 1 from inserted)returnany other option to check for no rowsIam a slow walker but i never walk back |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-08-28 : 03:57:34
|
if there is no matching records, there will not be any records being updated in the heathhistory table. And the trigger will not be fired. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2009-08-28 : 04:39:41
|
quote: Originally posted by khtan if there is no matching records, there will not be any records being updated in the heathhistory table. And the trigger will not be fired. KH[spoiler]Time is always against us[/spoiler]
hi,but trigger gets fired when i update table when the table has no records .i have used "on insert, update, delete"Iam a slow walker but i never walk back |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-08-28 : 05:50:15
|
inserted and deleted tables will be empty if no rows are affected KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|