Stop SQL Server Management Studio from breaking my view

I have a view that works perfectly fine and looks something like this:

WITH xxx AS ( ... ), yyy AS ( SELECT ... FROM xxx ) SELECT ... FROM yyy 

Pretty simple and it works great. However, a situation arose, and I need to make minor changes to xxx . I go into the view editor, make a small change to xxx, but when I save / execute, the Server Management Studio automatic format automatically switches and decides to change my view of this:

  WITH yyy AS ( SELECT ... FROM xxx), xxx AS ( ... ) SELECT ... FROM yyy 

It basically switches the first and second parts of my WITH statement for no apparent reason! I tried writing a script in a new query, making changes to it and recreating it, and it does the same.

Is there a way to turn off automatic formatting !? Any other suggestions !?

+6
source share
1 answer

The only way to win is to completely stop using the view designer.

You have to make a choice

  • either you care about the layout of the code in the view - in this case you write it yourself in the query editor window or
  • you view the view as completely created by the view designer, in which case you need to ignore what it looks like.
+1
source

Source: https://habr.com/ru/post/914167/


All Articles