Options

Introducing errors into UPDATE statement

Dave PendletonDave Pendleton Posts: 104 Bronze 3
edited December 16, 2007 7:53PM in SQL Refactor Previous Versions
The following SQL:
UPDATE dbo.MyTable SET MyColumn = 0 WHERE ...

Is refactored to:
UPDATE dbo.MyTable SET MyTable.MyColumn = 0 WHERE ...

when the "Qualify Object Names" functionality is used. This is, of course, wrong and will generate the following error:
Msg 1032, Level 15, State 1, Line X
Cannot use the column prefix 'MyTable'. This must match the object in the UPDATE clause 'dbo.MyTable'.

Correctly refactored, the statement should look like this:
UPDATE dbo.MyTable SET dbo.MyTable.MyColumn = 0 WHERE ...

Personally, I would prefer that SQL Refactor leave my UPDATE statements alone unless a FROM clause with an alias is present. I was unable to find a reference to this error in any previous posts, but I can't believe I'm the only one to encounter it.

Has this been logged as a bug, or am I missing a configuration option somewhere?

Comments

  • Options
    Thanks for taking the time to report this issue.

    I successfully managed to reproduce the fault using SQL Refactor 1.1, so I have logged a bug in our development database. The issue is now logged under the code SR-711.

    I will let you know the status once it has been reviewed by the development team.
    Chris
Sign In or Register to comment.