I am trying to see if I can store the values produced by function @@Error in a variable and, subsequently, print the value of the variable...
I understand that @@Error function automatically resets itself to 0 when it comes across a new line of code that is being evaluated, which means only the value of the last error is displayed but not the errors that comes before that.....
In the example below the value of the variable @myVariable is printed as 0, but that's because no errors were found and because the function was only used once. Could you give me an example where the code produces more than one error and the value of each @@Error is printed
Declare @myVariable int
insert into Employee
(62, 'Peter','Pan',GETDATE(),65,3,'Active','2002-08-12 00:00:00.0000000 -8:00','-8:00')
select @myVariable = @@Error
Print 'The value of Error is ' + convert(varchar,@myVariable)