Wednesday, March 21, 2012

Problem with [Left] in SQL Server 2005?

We have a table that contains a column named "Left". (Yea, I know, this was a bad idea - but it is not within my power to change it.)

Our stored procedures access it using [Left] without any problems in Sql Server 2000 and Sql Server Express Edition. HOWEVER, it does NOT work with SQL Server 2005. It generates the error: Column 'Left' is read-only.

Has anyone seen this? Is there a problem with SQL Server 2005 and reserved words using [ ] notation?

Thanks!

This is not a problem with the identifier (quoted or bracketed). The error message indicates that you are trying to modify the column using a query expression (CTE, view or derived table) and it is seen as read-only. Can you post a simple repro showing the problem? Or can you post the statement that is generating the error message.|||

We just tried running the stored procedure directly, and it works fine as well. So this must be a problem with ADO? Does that mean that I should be posting this question elsewhere? (Again, it works fine if we just reset the connection string to point to the database in SQL Server 2000 or SQL Server Express.)

This is a HUGE application that uses a form of the MS data block so it may be challenging (i.e. time consuming) to pull together a reasonably sized repro. But I'll see what I can get approval for ...

|||It could be something wrong in the client side. The client might be trying to update the query result (from query or view or SP). For example, you could be using wrong cursor type in the client code that might make the application think that a result is updateable. You could run a SQL Profiler trace to determine the statement from the client that is causing the error on the server. And there is no need to post the repro involving the client and the exact code. You should try to reproduce the problem independently using smaller set of tables and sample data. This is often the best way to isolate and understand the problem.|||

Found the problem. It had nothing to do with the [Left] actually. The stored procedure was doing a Union. The union seems to produce an updatable dataset in SQL Server 2000 and in SQL Server Express but NOT in Sql Server 2005.

Interesting ...

No comments:

Post a Comment