SQL Server reports 'Invalid column name', but the column is present and the query works through management studio Ask Question

SQL Server reports 'Invalid column name', but the column is present and the query works through management studio Ask Question

I've hit a bit of an impasse. I have a query that is generated by some C# code. The query works fine in Microsoft SQL Server Management Studio when run against the same database.

However when my code tries to run the same query I get the same error about an invalid column and an exception is thrown. All queries that reference this column are failing.

The column in question was recently added to the database. It is a date column called Incident_Begin_Time_ts .

An example that fails is:

select * from PerfDiag 
where Incident_Begin_Time_ts > '2010-01-01 00:00:00';

Other queries like Select MAX(Incident_Being_Time_ts); also fail when run in code because it thinks the column is missing.

Any ideas?

ベストアンサー1

Just press Ctrl + Shift + R and see...

In SQL Server Management Studio, Ctrl+Shift+R refreshes the local cache.

おすすめ記事