Alias added to computed column
a.higgins
Posts: 90 Bronze 2
Today I modified some code and added a computed column to a table variable:
When I apply formatting to this code snip, it adds an alias to the computed column, as follows:
Before formatting, the query works fine: after formatting, the query breaks.
Can you modify SQL Prompt to avoid adding alias to computed column specifications?
DECLARE @TableVar TABLE ( Col1 INT ,Col2 AS Col1 * 1 ) INSERT INTO @TableVar ( Col1 ) VALUES (1) SELECT tv.Col1 FROM @TableVar tv
When I apply formatting to this code snip, it adds an alias to the computed column, as follows:
DECLARE @TableVar TABLE ( Col1 INT ,Col2 AS [@TableVar].Col1 * 1 ) INSERT INTO @TableVar ( Col1 ) VALUES (1) SELECT tv.Col1 FROM @TableVar tv
Before formatting, the query works fine: after formatting, the query breaks.
Can you modify SQL Prompt to avoid adding alias to computed column specifications?
Comments
Thanks for reporting this issue. SQL Prompt shouldn't be qualifying column names for table variables.
We'll hopefully have a fix for this soon. Until then you can stop SQL Prompt attempting to qualify column names by unchecking SQL Prompt > Options > Inserted code > Qualification > Qualify column names with table name.
Cheers
Harry
I think this issue is fixed in this build: http://download.red-gate.com/EAP/SQLPro ... .0.236.exe
Column names should no longer be qualified inside their own table variable's definition. Please let me know if it works for you.
Cheers
Harry