Reputation: 2556
I have a stored procedure that is throwing an 'Invalid column name' error for 'ContentMarginExVat';
SELECT CategoryTitle, ContentID, ContentTitle, ContentMarginExVat, ContentWeight
FROM VWProductsCurrent
WHERE ContentID = @ContentID
I have checked both the VWProductsCurrents and the associated table that gets the data, both of these have the ContentMarginExVat selected, but yet the SQL Server Management Studio 2008 still says that the Column has an invalid name.
Wondered if anyone might be able to offer any advice on this?
Upvotes: 5
Views: 13889
Reputation: 43
Rename object_id to id
Ctrl+ Shift+R did not work for me even though it removed the squiggly lines and neither did silent's answer. After observing the script, I though maybe the name object_id was being confused with the function OBJECT_ID. I changed the object_id to id and it worked fine.
Upvotes: 0
Reputation: 1689
I had this problem with a query generated by SSMS when I selected "Select First 1000 Rows". Red squiggles under my column names and under my table name. But the query executed instantly and displayed the correct data.
After some Googling I found this link.
I pressed Ctrl-Shift-R to refresh the cache. Nothing happened immediately, but after about 5-6 seconds the squiggles went away on two tables where I was having this problem.
Upvotes: 7
Reputation: 69
i got this error when made changes on my backend but with a connection that was pointing to another copy of the backend that was not updated so i just had to change the connection string to the updated backend and it worked... ;-)
Upvotes: 0
Reputation: 3923
Try to execute this query and copy the column name to your query:
select
name
from
sys.columns
where
object_id = object_id('VWProductsCurrent')
or try to recompile your stored procedure with:
exec sp_recompile 'your_proc_name'
Upvotes: 2
Reputation: 453877
You need to run
exec sp_refreshsqlmodule 'VWProductsCurrent'
to refresh the metadata held about the view.
Upvotes: 4