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 |
Nil35
Starting Member
20 Posts |
Posted - 2014-09-25 : 10:43:48
|
need to create trigger on table which will not allow to update value "1" into column and if tried to update.. then it should show error massage "Good To GO"ID Name Roll1 Ron 12 Jon 03 Nil 34 Par 1if you try to update value "1" in Roll then it will through errornil |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-09-25 : 12:04:26
|
[code]create trigger dbo.tr_MyTable on MyTablefor Update -- Insert, too?asbegin if exists (select * from inserted where Roll = 1) raiserror("Good To GO", 16, 0) with LOG; -- "With LOG" is optionalend[/code]You probably want to modify or augment this logic but I think its a good start for your requirements. Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy |
|
|
Nil35
Starting Member
20 Posts |
Posted - 2014-09-25 : 14:12:33
|
Thank You so much John for reply,I tried this and its working but i dont want Value "1" updated in table above solution showing error massage but same time updating "1" in table can you plz help me out with this..nil |
|
|
Nil35
Starting Member
20 Posts |
Posted - 2014-09-25 : 14:55:24
|
I found the solution just using INSTEAD OF UPDATE in steade of FOR UPDATEThank You for Help Nilnil |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-09-25 : 18:27:30
|
My error handling should have included a rollback statement. When the code is free, sometimes you only get whacha pay for... Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy |
|
|
|
|
|