Thank you for Speedy response.
my question is, when i print the values from trigger
but as per my table id's 1 and 2 are updting, i want 1 and 2 values to be print as output.
triggers in SQL have to assume they are touching more than one row of data; as soon as you assign a value(ie SELECT @id = ID FROM INSERTED) you break that rule; if there are multiple rows in the insert/update, you end up getting the first or last row of the data assigned to the variable...and you don't know which one it was.
so for a spot check during development, yeah maybe i'd see a variable, but it should not exist once your testing is complete.
in general, if i see a variable in a trigger, i assume it's written incorrectly.
this is one of the first spot checks i run when reviewing a new-to-me database
--triggers have variables defined?
select * from sys.triggers where object_definition(object_id) like '%@%'
if this command was inserted, which values, woudl you think appear in your print statments? there are four values to choose from for each column:
INSERT INTO Test([ID],[Name],[Desc])
SELECT '1','D','Desk' UNION ALL
SELECT '2','D','Desk1' UNION ALL
SELECT '3','X','TBT1' UNION ALL
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!