Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Views and their formatted text being lost Expand / Collapse
Author
Message
Posted Monday, October 21, 2013 10:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 16, 2014 3:16 PM
Points: 4, Visits: 56
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.
Post #1506755
Posted Monday, October 21, 2013 11:46 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: 2 days ago @ 8:21 AM
Points: 547, Visits: 1,877
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 ...
Post #1506776
Posted Monday, October 21, 2013 12:30 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 16, 2014 3:16 PM
Points: 4, Visits: 56
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.
Post #1506792
Posted Monday, October 21, 2013 4:48 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:30 PM
Points: 14,802, Visits: 27,275
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 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1506916
Posted Tuesday, October 22, 2013 3:26 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 10:09 AM
Points: 1,207, Visits: 9,333
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?
Post #1507030
Posted Tuesday, October 22, 2013 8:52 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, April 10, 2014 1:16 PM
Points: 101, Visits: 311
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.
Post #1507197
Posted Friday, October 25, 2013 12:27 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:25 AM
Points: 7,070, Visits: 12,523
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1508337
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse