1
Answer

if a record exists in the table, run a procedure

Photo of Enrique Romero

Enrique Romero

10y
650
1
I'm trying to run a procedure, once it finds a record in a table, in which, if you find the record, verifies that record type is another value stored in another column, if not found, save a data in a variable that is already declared.

IF Exists(SELECT *
FROM    [Roga].[dbo].[RFC_Empresa_Buzon_Fiscal]
WHERE RFC = @eRFC)
SELECT    TOP(1)
        RTRIM(LTRIM(REPLACE(RFC, ' ', '')))                AS    RFC,
        RTRIM(LTRIM(Tipo))                AS    Tipo,
        RTRIM(LTRIM(Razon_Social))    AS    Razon
FROM    [Roga].[dbo].[RFC_Empresa_Buzon_Fiscal]
WHERE    RTRIM(LTRIM(REPLACE(RFC, ' ', ''))) LIKE @eRFC
ELSE
SET
@eRFC = 'RFC No Valido'


This is what I wear, what I need is that the value of the "Tipo" column, is stored in a variable, which will use later to call it from C #, could guide me, I'm new to SQL Server.

Thank you

Answers (1)

1
Photo of Manish Dwivedi
NA 8.3k 1.2m 14y

Hi will,
for str, single character is converted to its relevant ASCII value.
Same is happen for str2 , taking ASCII value for characters(Here fix string is AMEND, you have to make it large like AMENDING)
and str3 we are taking the difference of ASCII value.

and making the format like that 1245/2543/475812
and in last line the value you got is converted to datetime.
This is the working og this code, but still i didn't get the purpose of code.
 
 
 


 
Anybody wish to share with me how this code actually works?
 
Accepted
0
Photo of Will
NA 3 1.8k 14y

Thank You very much for your answer.
I had worked out that it was subtracting from the ASCII value of each character in the str2 "string" moments before you post, and have since made the code work how I required :)
Regards :)