wise-coders / dbschema

DbSchema Database Designer
https://dbschema.com
67 stars 3 forks source link

How to include batch separator, GO, in generated schema script, SQL Server #36

Closed zhsc closed 3 years ago

zhsc commented 3 years ago

I'm using version 8.3.4 build 201214 on windows against SQL Server 2019 database.

When I export a schema creation script via Schema -> Export Schema Script and Data it generates a script mostly correctly. However, it doesn't include batch separators like "GO" between certain key operations like the "CREATE SCHEMA xyz". When the script is ran as-is via MS SQL Server Management studio (SSMS), it throws errors like:

Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword 'CREATE'.

Example of the first few lines of the script:

CREATE SCHEMA xyz;

CREATE TABLE xyz.test ( 
    test_id            int NOT NULL
 );

But if you separate the statements with "GO" (the batch separator) it runs correctly. e.g.

CREATE SCHEMA xyz;
GO

CREATE TABLE xyz.test ( 
    test_id            int NOT NULL
 );
GO

Is there some way to enable these separators to be emitted?
It does run fine when executed directly from DbSchema UI, just the generated script doesn't work in other tools (kind of defeating its purpose).

Thanks

wise-coders commented 3 years ago

Thank you for reporting this issue. The next DbSchema minor release will include a fix for this.

zhsc commented 3 years ago

Just for my reference, when about do new versions typically get pushed out? I understand hard to give a firm date, but just a rough guess would help

wise-coders commented 3 years ago

We already created a beta version: https://dbschema.com/beta.php Please let me know if is working fine.

zhsc commented 3 years ago

Just tested and it's working great. Thanks for the quick turnaround!

wise-coders commented 3 years ago

Great, thank you for your feedback!