I am trying to write a SQL statement in Python: 'attribute' is a column name that I want to change its format and I am giving it as a parameter. Because its name can be different.
cur.execute("SELECT DATEADD(y," + attribute + ", '1980-01-01')")
But I am getting below error. attribute=Date1 and this column exists.
question from:https://stackoverflow.com/questions/65640822/getting-error-that-invalid-column-name-while-writing-sql-statement-in-python[42S22] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid column name 'Date1'. (207) (SQLExecDirectW)"