Alignment BUG
torsten.strauss
Posts: 271 Silver 3
Hi!
The following statement is formatted like this:
[code]
-- Start the session io_reads
IF NOT EXISTS
(
SELECT *
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = START;
GO
-- Watch event session
-- Execute with a non selective value : 0
-- Actual number of rows : 9994
-- Estimated number of rows : 100 ?
-- SQL Server cannot expand the multi statement table valued function
-- No use of statistic cause of the use of a table variable in the multi statement
-- table value function
-- Tabled variables do not have any statistics
-- Table '#A98990E0'. Scan count 1, logical reads 21
-- Event session : logical_reads 11412
SELECT *
FROM
mtvf_statisitc(0)
;
GO
-- Stop the session
IF NOT EXISTS
(
SELECT
*
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = STOP;
GO
IF NOT EXISTS
(
SELECT *
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = START;
GO
-- Watch event session
-- Execute with a non selective value : 0
-- Actual number of rows : 9994
-- Estimated number of rows : 100 ?
-- SQL Server cannot expand the multi statement table valued function
-- No use of statistic cause of the use of a table variable in the multi statement
-- table value function
-- Tabled variables do not have any statistics
-- Table '#A98990E0'. Scan count 1, logical reads 21
-- Event session : logical_reads 11412
SELECT *
FROM
mtvf_statisitc(0)
;
GO
-- Stop the session
IF NOT EXISTS
(
SELECT
*
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = STOP;
GO
[/code]
The issues start with the first GO which is not aligned. Therefore it seems that the entire code is sent one tab to the right.
I have even examples here where this bug is cascading which ends up with code which is ten tabs to the right.
BTW It took me one hour to reformat my code because the only solution seems to highlight every batch one by one and format...
Please fix this bug- thanks!
Torsten
MVP
SQL Prompt Version 9.4.6.7396
Tagged:
Answers
You're saying this is not what you want?
Thanks for looking into this!
The issue is that the statement after the GO is shift one tab to the right.
If you format the batches one by one you will see that the tab is gone correctly
This behaviour leads to a formatted code which will be shifted to the right after each GO (or for other reasons)
In the end your entire code is completely out of alignment
IF NOT EXISTS
(
SELECT *
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = START;
GO
-- Start the session io_reads
IF NOT EXISTS
(
SELECT *
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = START;
GO
-- Start the session io_reads
IF NOT EXISTS
(
SELECT *
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = START;
GO
-- Start the session io_reads
IF NOT EXISTS
(
SELECT *
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = START;
GO
-- Start the session io_reads
IF NOT EXISTS
(
SELECT *
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = START;
GO
-- Start the session io_reads
IF NOT EXISTS
(
SELECT *
FROM
sys.dm_xe_sessions
WHERE
name = N'io_reads'
)
ALTER EVENT SESSION io_reads
ON SERVER STATE = START;
GO