if a record exists in the table, run a procedure
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