I have
cursor.execute("select RM_ID FROM Sales.dbo.MARKETING where VERSION = 'SomeVersion'")
which gives me the traceback error:
pyodbc.ProgrammingError: ('42S02', "[42S02] [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'Sales.dbo.MARKETING'. (208) (SQLExecDirectW)")
I have several other lines of code:
cursor.execute("select RUNDATEEST FROM Sales.dbo.MARKETING where VERSION = 'SomeVersion'")
that are exactly the same except for the column name that give me no error. I'm not sure what my mistake is.
Of note:
This typically means 1 of 2 things... you've referenced an object (table, trigger, stored procedure,etc) that doesn't actually exist (i.e., you executed a query to update a table, and that table doesn't exist). Or, the table exists, but you didn't reference it correctly...
In a SQL statement, you represent the name of an object with a quoted identifier or a nonquoted identifier. A quoted identifier begins and ends with double quotation marks ("). If you name a schema object using a quoted identifier, then you must use the double quotation marks whenever you refer to that object.
An invalid column name error in SQL means that the column name violates the conditions of the column name. If you reference an object that does not exist in the table or the name exists, but you did not reference it correctly, you will get this error.
Try to surround schema and table names with brackets:
[Sales].[dbo].[MARKETING]
Perhaps you need to surround column names in the same way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With