I would like to know if I can declare a variable where its contents is the name of a column, I tried the example below and it did not work.
DECLARE @P1 VARCHAR(3)
SET @P1 = 'CPF'
SELECT *
FROM dbo..table A
WHERE @P1 = '123456789'
The following is a sample table:
CPF NAME
-----------------------
123456789 Luis
987654321 Rafael