SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Views and their formatted text being lost


Views and their formatted text being lost

Author
Message
kipper_007
kipper_007
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 71
Issue: When editing a view (right click view, click 'Script view as', click 'alter to', 'click 'New query window'), all the formatting I spent hours and hours perfecting is lost!!

When editing a stored procedure, all the formatting is how I last left it.

Is there a way to keep the formatting in a view. It seems a waste of time to re-align column etc. each time.

Thanks.
Nevyn
Nevyn
Hall of Fame
Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)

Group: General Forum Members
Points: 3344 Visits: 3149
Sorry to be captain obvious, but you could always save your nicely formatted view definition as a file, and open it when you need it as opposed to doing a "script as". With the added bonus that you could then implement versioning or source control on the definition as well ...
kipper_007
kipper_007
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 71
Thanks for the suggestion, but we already use Redgate for source control. Keeping a copy of the view in a file is an option, but does add redundancy to the picture.

I'll investigate if redgate source control tool can help and update. That was something I didn't think about.
Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)

Group: General Forum Members
Points: 94449 Visits: 33010
One thing you can do is to use Red Gate SQL Prompt to format the query, whether it gets saved correctly or not.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
HowardW
HowardW
SSCertifiable
SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)

Group: General Forum Members
Points: 5929 Visits: 9892
Views maintain their formatting when created/altered like any other object. Is this a problem with how they're being applied in your deployment process/stored in Source Control?
R. Brush
R. Brush
Old Hand
Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)

Group: General Forum Members
Points: 379 Visits: 352
May not be the issue here, but in SSMS, if someone opens the view using <Right-Click> Design, opening the view in the Query Designer, and then saves it, the formating and comments will be lost.
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)

Group: General Forum Members
Points: 37390 Visits: 14411
The nice features in the Query Designer that allow you to drag and drop tables into the query, drag columns around to complete joins, etc. means the UI takes control of the query text so it can present what was designed in the visual areas of the designer in the query text pane. Not much you can do about that. And unfortunately redgate SQL Prompt doesn't work its magic in the Query Designer.

If you want ultimate control over your query formatting use the Query Window by right-clicking on the View, selecting Script View As, then Alter, then New Query window. From there you will be working with the actual view-definition, but of course only in its textual form. Altering the view in a Query Window will maintain its formatting whereas working with it in the Query Designer will not.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search