Introducing errors into UPDATE statement
Dave Pendleton
Posts: 104 Bronze 3
The following SQL:
Is refactored to:
when the "Qualify Object Names" functionality is used. This is, of course, wrong and will generate the following error:
Correctly refactored, the statement should look like this:
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?
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
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.