Options

Formatting in 7.3.0.522: Why is it wrapping like this?

JimFJimF Posts: 49 Bronze 3
edited September 14, 2016 6:53AM in SQL Prompt
I created a restore script for someone to use, then formatted the SQL. FYI, my wrapping is set to 200.
Use master

Alter Database ABitLongerDatabaseName
Set Single_User
With Rollback Immediate

Restore Database ABitLongerDatabaseName
    From Disk = N'F:BackupsABitLongerDatabaseName.bak'
    With File = 1,
         NoUnload,
         Replace,
         Stats = 5

Alter Database ABitLongerDatabaseName Set Multi_User

Go

First, I am wondering why the first Alter Database wraps and the final one does not. I don't mind it wrapping lines that are less than the 200 that I set, but shouldn't they be consistent?

Second, I like how the Restore Database was indented when formatted on multiple lines. Can the Alter be done a similar way and not all left justified? Considering the way the Restore Database is wrapped, I think it should look more like this.
Use master

Alter Database ABitLongerDatabaseName 
    Set Single_User 
    With Rollback Immediate

Restore Database ABitLongerDatabaseName
    From Disk = N'F:BackupsABitLongerDatabaseName.bak'
    With File = 1,
         NoUnload,
         Replace,
         Stats = 5

Alter Database ABitLongerDatabaseName 
    Set Multi_User

Go

As usual, great product and keep up the good work,
Jim

Comments

  • Options
    Aaron LAaron L Posts: 596 New member
    Hi Jim,

    Thanks for your post!

    I think the second Alter Database statement might be collapsed onto a single line due to the "Collapse statements short than x characters" setting on the DDL page. If you untick this setting (or alternatively, increase it large enough to collapse the first statement) does it work as you'd expect?

    It looks like the issue with the clauses not being indented (even with the "Indent clauses" option being ticked on the DDL page) for alter databases is a bug so we'll look into fixing this now.

    Thanks,
    Aaron.
Sign In or Register to comment.