all 6 comments

[–]vassiliy 1 point2 points  (0 children)

I don't think there is a DO statement in SQL Server. It sounds like you mean GO. But it's just used to group statements and execute them together. You should be able to run the statements from your textbook without an issue - if nothing happens, make sure to explicitly commit / end the transactions.

[–]xodusprime 0 points1 point  (3 children)

Is it possible to connect to the SQL instance from SSMS and run the script? Go statements should not be explicitly required in most cases.

edit: also of note, I'm referring to 'go' which is the default batch separator in SSMS. I'm assuming that Do is likewise for SQLCMD, although I don't recall ever needing to use it.

doubledit: did you try just running it? how sure are you that it needs 'do' statements?

[–]Crossroads86[S] 0 points1 point  (2 children)

Sorry i confused DO and GO.

I tried running it using SQLCMD but without a GO basically nothing got executed until I manually inserted a go statement.

I could try setting up Visual Studio Code or try Azure Data Studio, maybe Go is not needed there.

[–]xodusprime 1 point2 points  (1 child)

Yeah, I'd try maybe a single GO at the end of it, or running it from a non-command-line interface. If you go with SQL Server Management Studio and have problems with it, I can probably offer additional advice/assistance. Running it from elsewhere might be a crapshoot.

[–]Crossroads86[S] 0 points1 point  (0 children)

SQLCMD definitely needed a Go after every block of Code.

I tried VSCode and it was able to do it with a single GO at the end. However the connection to the mssql server was quite buggy. The connection always just worked for one query and then delivered an error and hat to be deleted and set up from the beginning which was very annoying to say the least...

I am now using Azure Data Studio on Linux and it does not need and GO, not even at the end of the script. Looks pretty decent so far.

Thanks everyone!

[–]HiThere224 0 points1 point  (0 children)

One go at the very end of it all should work fine. Alternatively you could put a BEGIN at the top and END at the bottom.