Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invalid column name

Status
Not open for further replies.

INFORMAT

Programmer
Jan 3, 2001
121
0
0
BE
Hi,

I wrote a query in the query analyser and it works just fine. When I want to use the exact same query in a stored procedure, he gives me this error: Invalid column name ... .
This error occurs in the where clause where he has to compare with a parameter. This parameter is a string. I had this error in other stored procedures, but i solved it there by putting the parameter between " ", like this "'+parameter+'". Now it just doesn't help a bit.

could someone please help me?

>:):O> Björn

 
You must put the OWNER.TABLENAME.COLUMNNAME if the table has a different owner than the stored procedure, Example:

If I was listed as the owner of a table and dbo is the owner of the stored procedure, to reference a column I would have to type atkisad.tblInventory.Orders

If the table and stored procedure have the same owner then you only would use tblInventory.Orders

This is the reason you should have all stored procedures, views, and tables owned by the dbo.

Hope this helps

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top