July 22, 2012 at 10:21 am
Hi
This is vivek.I want create trigger on emp it won't allow insert and update records in to emp sal less than 500.
please give me replay.
Thanks&Regards,
vivek,
July 22, 2012 at 10:48 am
Trigger is not required here. Alter your table to include CHECK Constraint with specified salary options.
Check the below links for implementation:
http://msdn.microsoft.com/en-us/library/ms188258%28v=sql.105%29.aspx
http://msdn.microsoft.com/en-us/library/ms179491%28v=sql.105%29.aspx
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
July 22, 2012 at 10:53 am
Don't know the exact structure of the employee table you are using, but code would be something like this-
ALTER TABLE dbo.Employee
ADD CONSTRAINT CONS_Salary_nlt_500
CHECK (Salary > 500)
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
July 22, 2012 at 10:59 am
A little difficult to understand what you are requesting, but if what you want to prevent is that a Salary amount can't be less than 500.00, all you need is a constraint on the column to states salry must be >= 500.00.
July 22, 2012 at 11:47 am
lokeshvij (7/22/2012)
Check the below links for implementation:
http://msdn.microsoft.com/en-us/library/ms188258%28v=sql.105%29.aspx
http://msdn.microsoft.com/en-us/library/ms179491%28v=sql.105%29.aspx%5B/quote%5D
It is much more helpful if you surround the URLs you post with the [ url ]/[ /url ] IFCode Shortcuts (no spaces inside the square brackets).
http://msdn.microsoft.com/en-us/library/ms188258%28v=sql.105%29.aspx
http://msdn.microsoft.com/en-us/library/ms179491%28v=sql.105%29.aspx
Doing this, you don't have to cut/paste to check them out.
July 22, 2012 at 11:51 am
Taken:-)
Next time for sure..
- Lokesh
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply