SQL syntax problem (multiple selects)
Posted
by user279521
on Stack Overflow
See other posts from Stack Overflow
or by user279521
Published on 2010-06-18T14:59:59Z
Indexed on
2010/06/18
15:03 UTC
Read the original article
Hit count: 277
sql-server-2005
|tsql
I am having problems retrieving accurate data values with my stored proc query below:
CREATE PROCEDURE usp_InvoiceErrorLog
@RecID int
AS
DECLARE @ErrorString as varchar(1000),
@ErrorCode as int;
Select @ErrorCode = ErrorCode from tbl_AcctRecv_WebRpt Where RecID = @RecID;
IF NOT(@ErrorCode = NULL)
Begin
Select @ErrorString = ErrorDesc from tbl_ErrDesc Where ErrorCode = @ErrorCode
End
Select RecID, VendorNum, VendorName, InvNum, InvTotal, (SELECT CONVERT(VARCHAR(11), InvDate, 106) AS [DD MON YYYY]) As InvDate,
TicketRequestor, ErrorCode, @ErrorString as ErrorDesc
from tbl_AcctRecv_WebRpt Where RecID = @RecID
The ErrorDesc column (in the final select statement at the bottom) returns a NULL value, when it should return a valid string data.
Any ideas?
© Stack Overflow or respective owner