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
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: 2 days ago @ 11:25 AM
Points: 637, Visits: 2,143
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: 2 days ago @ 3:50 AM
Points: 13,991, Visits: 28,373
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
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: Monday, November 3, 2014 8:05 AM
Points: 1,191, Visits: 9,892
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: Friday, November 14, 2014 8:41 AM
Points: 101, Visits: 323
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: Yesterday @ 6:23 PM
Points: 7,135, Visits: 12,743
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
Post #1508337
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse