Strange situation In a trigger i assign a column value to variable but gives exception while inserting into other table using that variable.
e.g
select @srNO=A.SrNo from A where id=123;
insert into B (SRNO) values (@srNo) // here it gives null
I run above select query in query pane it works fine but in trigger it gives me null
any suggestions
ALTER PROCEDURE ProcessData
@Id decimal(38,0),
@XMLString varchar(1000),
@Phone varchar(20)
AS
DECLARE
@idoc int,
@iError int,
@Serial varchar(15),
@PhoneNumber varchar(15),
BEGIN
COMMIT TRAN
EXEC sp_xml_preparedocument @idoc OUTPUT,@XMLString<br/>
SELECT @iError = @@Error<br/>
IF @iError = 0<br/>
BEGIN<br/>
SELECT @Serial = convert(text,[text]) FROM OPENXML (@idoc,'',1) where nodetype = 3 and ParentId = 2
IF @Serial=Valid <br/>
BEGIN<br/>
BEGIN TRAN INVALID<br/>
begin try <br/>
Declare @phoneId decimal(38,0);<br/>
SELECT @phoneId = B.phoneId FROM A
INNER JOIN B ON A.Id = B.Id WHERE A.PhoneNumber like '%'+@SenderPhone + '%'<br/>
print @phoneId ; //gives null<br/>
end try<br/>
begin catch<br/>
print Error_Message();<br/>
end catch<br/>