May 13, 2010 at 12:28 pm
Hello
I have same problem to create trigger i create two tables 1) is Cusotmer profiles and 2)Customer Buy
1) Customer profile table consist 4 fields
CustomerID CustomerName CustomerBalance Status
02 Jack 4500 Disable
2) CustmerID Producet Qty TotalAmount
02 Fish 4 350
02 Oil 1 150
i want to create trigger that if Customer profile status field is (Disable).block insert new enter in CustomerBuy table where CustomerID 02
create trigger block on CustomerBuy
for insert
as
if insert(CustomerBuy.Client)
begin
if exists (select status from inserted where status='Enable')
rollback
end
May 13, 2010 at 12:47 pm
Three clues...
1- Triggers are created in a table.
2- Trigger has to know when to fire - insert? delete? update?
3- If you want trigger to insert in another table, you have to write insert statement.
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy