Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
please check my trigger code

SQL
SET @priority = (SELECT dbo.Jobs.ProcessStatus FROM dbo.Jobs WHERE dbo.Jobs.ProcessStatus = @NotificationTypeID);

        IF(@priority = 1)
        Begin
            SET @NotificationTypeID = 1;
            SET @NotificationType='Normal';
            End
        ELSE
            IF(@priority = 2)
            Begin
            SET @NotificationTypeID = 2;
            SET @NotificationType='Critical';
        END
Posted
Comments
Richard Deeming 13-Jul-15 7:49am    
Are we supposed to guess what error you're getting?

1 solution

It would really help if you would post the error you encountered but...

Based on the code you provided you most likely encounter a problem that your query tries to fetch multiple rows into a single variable. This one
SQL
SET @priority = (SELECT dbo.Jobs.ProcessStatus FROM dbo.Jobs WHERE dbo.Jobs.ProcessStatus = @NotificationTypeID);

If that's true you have few choices:
- ensure that you select only one row by modifying the conditions
- create a loop using a cursor where you handle all the returned rows
- instead of cursor use a single statement to make modifications in the database (if you're modifying the data)

If the error is something different, please post the full description.
 
Share this answer
 
Comments
Sanjay K. Gupta 13-Jul-15 7:58am    
You have given the solution without knowing the error. Brilliant! +5
Wendelius 15-Jul-15 8:53am    
Thank you, I hope it helped the OP

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900