sql server 2005 - Strange "Invalid column name" error when executing SP -


We have a SP in which we create a query and then execute the query using exec (@select) Do call, where the SQL query contains the variable is in it @select .

I have been requested to add a new column for the results. This new column returned by SP should not be returned in all circumstances, but only under a certain condition. Naturally, I added the following code to SP.

  If set up @conditionIsMet BEGIN @select = @select + ", 'compqty' = convert (varchar (53), di.qty)" END  
< P> It works fine till today, when a SQL exception with my app message is throwing, "invalid column name: compact". This is uncertain and the exception does not always throw.

Executing SP in SQL Server Management Stew does not give any error If the column title is provided with 'compact' then the app should pick up the column, but it does not seem like !

Can anyone help?

'compqty '


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -