Skip to content

treat GO as ; if transactsql and split lines #914

Open

Description

@bobbymannino

If the language is TSQL, it is frequent that GO will be used instead of ;, especially in stored procedures, so it would be nice to have the option to set line splitters (maybe call them something better?) other then just ;, possible even comments could be, but for now this would be really nice in formatting the SQL to be prettier

Activity

  1. nene commented on Oct 24, 2025

    @nene
    Collaborator

    I'm not really sure I understand how you expect this to work. It would be better if you gave an example. Like how does SQL Formatter print GO right now and how would you like it to be treated instead?

  2. bobbymannino commented on Oct 24, 2025

    @bobbymannino
    Author
    -- current behavior
    set
    ansi_nulls on
    go
    set
    quoted_identifier on
    go
    create procedure aspDoSomething @pStartSerialNo varchar(20),
    @pEndSerialNo varchar(20) as begin
    -- code goes here
    select 
      1;
    
    end
    go
    -- desired behavior
    set
    ansi_nulls on
    go -- line break after go
    
    set
    quoted_identifier on
    go -- line break after go
    
    create procedure aspDoSomething -- not in this issue but would be nice to split parameters of stored procedures and indent them, but thats a separate topic
      @pStartSerialNo varchar(20),
      @pEndSerialNo varchar(20) 
    as 
    begin
    -- code goes here
    select 
      1;
    
    end
    go -- line break after go
    

    you cannot put GO with ; in a stored procedure file before create procedure x because it needs to be the first statement in a query (silly clause i know but thats SQL Server)

  3. nene commented on Oct 24, 2025

    @nene
    Collaborator

    OK. Thanks.

    Basically should format GO on separate line (like now) and add an additional line break after it.

  4. bobbymannino commented on Oct 24, 2025

    @bobbymannino
    Author

    yeah, i am pretty sure the keyword GO is only used in TSQL too (maybe that makes a difference?)

    thank you @nene

  5. kkum commented on Jul 21, 2026

    @kkum

    Hello thanks for this library,

    I have the same request as i get errors for how the formatting works,

    here is my config

      "SQL-Formatter-VSCode.dialect": "transactsql",
      "SQL-Formatter-VSCode.dataTypeCase": "lower",
      "SQL-Formatter-VSCode.functionCase": "lower",
      "SQL-Formatter-VSCode.identifierCase": "lower",
      "SQL-Formatter-VSCode.ignoreTabSettings": true,
      "SQL-Formatter-VSCode.keywordCase": "lower",
      "SQL-Formatter-VSCode.paramTypes": {},

    Here is what i expect

    set
    ansi_nulls on
    go
    
    set
    quoted_identifier on
    go
    
    drop view if exists [my_schema].[my_view]
    go
    
    create view [my_schema].[my_view] as
    select
      *
    from
      [my_schema].[my_table]
    go
    

    Here is what i get
    Note the go drop on line 6 that is no valid sql

    set
    ansi_nulls on
    go
    set
    quoted_identifier on
    go drop view if exists [my_schema].[my_view]
    go
    create view [my_schema].[my_view] as
    select
      *
    from
      [my_schema].[my_table]
    go

    I'd be happy to send a PR, can you just point the main file where this could be handled ?
    thanks

  6. bobbymannino commented on Jul 22, 2026

    @bobbymannino
    Author
  7. nene commented on Jul 23, 2026

    @nene
    Collaborator

    Well, there's currently no real way to add a formatting rule for a specific dialect. So editing that file is probably not much help.

    One likely needs to modify the ExpressionFormatter to add a special formatting for the GO keyword. Though it likely makes sense to do special classification of the GO keyword, so it's only detected in case of TransactSQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions