Using Trigger -- For this scenario

Posted by Naraayanan under Sql Server on 11/4/2013 | Points: 10 | Views : 1304 | Status : [Member] | Replies : 3
Hi All,
create one table, table name is USER MASTER. The following fields are in the User Master
1)User Id
2)User Name
3) Password
4)Age
5)EligibleforLogin

if age is greater than 18 , automatically , true status update into EligiableforLogin otherwise no. how to do this using trigger ?

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/



Responses

Posted by: Bandi on: 11/4/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
try this...
CREATE TRIGGER Tr_Insert 

ON [USER MASTER]
FOR INSERT
AS
BEGIN
UPDATE um SET um.EligibleforLogin = CASE WHEN i.Age >=18 THEN 'Y' ELSE 'N' END
FROM [USER MASTER] um
JOiN inserted i ON um.[User Id] = i.[User Id]

END


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 11/4/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
I have updated the above post...
Check now


NOTE:
Click on "Mark as Answer " if the above post helped you; otherwise post us back with proper explanation of the issue

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 11/4/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Mark it as answer

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response