I've being trying to figured out why this error is happening but no lucky yet.
The code:
SELECT CONVERT(VARCHAR, OPER.DATE_OPER, 112) + ' ' + -- DATE OPER YYYYMMDD CONVERT(VARCHAR, OPER.OPE_TIME, 102) + ' ' + -- OPE TIME HH:MI:SS FNUMBER.FILE_SEQUENCY_REND + ' ' + -- BATCH NUMBER RIGHT(REPLICATE('0',16) + CONVERT(VARCHAR(16), DBO.F_EXTRACT_NBR_CHAR(RECEIVER.C_CPF)),16) + ' ' + -- RECEIVER CPF / CNPJ DBO.FN_FORMAT_RIGHT_SPACES(RECEIVER.C_NAME, 40) + ' ' + -- RECEIVER NAME RIGHT(REPLICATE('0',14) + CONVERT(VARCHAR(14), DBO.F_EXTRACT_NBR_CHAR(RECEIVER.C_PHONE1)),14) + ' ' + -- RECEIVER PHONE NUMBER DBO.FN_FORMAT_RIGHT_SPACES(RECEIVER.C_ADDRESS, 50) + ' ' + -- RECEIVER ADDRESS DBO.FN_FORMAT_RIGHT_SPACES(RECEIVER.C_CITY, 20) + ' ' + -- RECEIVER CITY DBO.FN_FORMAT_RIGHT_SPACES(ACC.ACCOUNT_STATE) + ' ' + -- RECEIVER STATE RIGHT(REPLICATE('0',14) + CONVERT(VARCHAR(14), DBO.F_EXTRACT_NBR_CHAR(RECEIVER.C_ZIP)),14) + ' ' + -- RECEIVER ZIP DBO.FN_FORMAT_RIGHT_SPACES(RECEIVERCOUNTRY.COUNTRY , 20) + ' ' + -- RECEIVER COUNTRY RIGHT(REPLICATE('0',3) + CONVERT(VARCHAR(3), ISNULL(S_BANK.BANK_NUMBER, 0)),3) + ' ' + -- BANK NUMBER DBO.FN_FORMAT_RIGHT_SPACES(ACC.AGENCY, 30) + ' ' + -- AGENCY DBO.FN_FORMAT_RIGHT_SPACES(ACC.ACCOUNT, 16) + ' ' + -- ACCOUNT NUMBER (CHAR) LEFT(ISNULL(ACC.ACCOUNT_TYPE, 'C/C'), 1) + ' ' + -- ACCOUNT TYPE DBO.FN_FORMAT_RIGHT_SPACES(SENDER.C_NAME, 40) + ' ' + -- SENDER DBO.FN_FORMAT_RIGHT_SPACES(SENDER.C_CUSTOMER_ID, 40) + ' ' + -- SENDER ID DBO.FN_FORMAT_RIGHT_SPACES(SENDER.C_ADDRESS, 50) + ' ' + -- SENDER ADDRESS DBO.FN_FORMAT_RIGHT_SPACES(SENDER.C_CITY, 20) + ' ' + -- SENDER CITY DBO.FN_FORMAT_RIGHT_SPACES(ACC.ACCOUNT_STATE,2) + ' ' + -- SENDER STATE RIGHT(REPLICATE('0',14) + CONVERT(VARCHAR(14), DBO.F_EXTRACT_NBR_CHAR(SENDER.C_ZIP)),14) + ' ' + -- RECEIVER ZIP DBO.FN_FORMAT_RIGHT_SPACES(SENDERCOUNTRY.COUNTRY , 20) + ' ' + -- SENDER COUNTRY RIGHT(REPLACE(REPLICATE('0', 15) + CAST(CAST(AMOUNT * RATE AS NUMERIC(15,2)) AS VARCHAR), '.', '') ,15) + ' ' + -- FOREING AMOUNT 'L' + ' ' + -- CURRENCY TYPE L = LOCAL / D = DOLLAR 'N' + ' ' + -- TRANS TYPE - N=NEW OR V=VOID RIGHT(REPLICATE('0',10) + CONVERT(VARCHAR(10), OPER.OPE_NUMBER),10) + ' ' + -- OPERATIONS NUMBER SPACE(20) + ';' + -- LIVRE SPACE(80) -- LIVRE AS LINE, OPER.DATE_OPER, OPER.OPE_TIME, OPER.FOREING, OPER.OPE_NUMBER, OPER.OPE_SUBNUMBER, OPER.MAKER, OPER.AMOUNT, OPER.FEE_AMOUNT, ISNULL(OPER.COM_STAR,0) AS COM_STAR FROM S_OPERATION OPER, S_FILE_NUMBER FNUMBER JOIN S_CUSTOMER SENDER ON OPER.SENDER_ID = SENDER.C_CUSTOMER_ID JOIN S_CUSTOMER RECEIVER ON OPER.RECEIVER_ID = RECEIVER.C_CUSTOMER_ID JOIN S_COUNTRY SENDERCOUNTRY ON SENDER.C_COUNTRY_ID = SENDERCOUNTRY.COUNTRY_ID JOIN S_ACCOUNT ACC ON OPER.ACC_ID = ACC.ACCOUNT_ID JOIN S_BANK ON ACC.BANK_ID = S_BANK.BANK_ID JOIN S_OPERATIONATION_PAYERBATCH ON OPER.OPE_NUMBER = S_OPERATIONATION_PAYERBATCH.OPE_NUMBER WHERE S_OPERATIONATION_PAYERBATCH.IDPAYERBATCH = @IDPAYERBATCH
The error:
Msg 4104, Level 16, State 1, Procedure sp_generate_payerbatch, Line 208 The multi-part identifier "OPER.SENDER_ID" could not be bound. Msg 4104, Level 16, State 1, Procedure sp_generate_payerbatch, Line 211 The multi-part identifier "OPER.RECEIVER_ID" could not be bound. Msg 4104, Level 16, State 1, Procedure sp_generate_payerbatch, Line 217 The multi-part identifier "OPER.ACC_ID" could not be bound.
Thanks for any help