I am trying to use date data type as a variable in a select query , I would want to replace the date column name dynamically by declaring it as a variable but this fails with a syntax error.
DECLARE @DATE_VAR VARCHAR(10) SET @DATE_VAR = 'Visit_date'
--print @date_var
SELECT @DATE_VAR from Maternity_DB.dbo.Visit_table
WHERE @Date_Var> getdate() - 10