Essentially i need to run a quite large SQL script that wont run in SSMS.
Using sqlcmd to input a .sql file however will simply seem to stop at first GO statement it reaches.
All it seems to run is:
USE [master]
GO
CMD writes: “Changed database context to ‘master'”
And then its idle, no cpu usage and bare minimal ram usage.
Even with minimized script just to create a new, empty DB, the result is the same.
the string i used would be like this:
sqlcmd -S 127.0.0.1 -U x -P x -i D:\x\f.sql
it connects to the db just fine, however the included .sql script still wont run.
Setting errorlevel to 1 wont help, it still stops/halts, simply no message then.
I think you’ve got GO in the wrong place.
I use sqlcmd for a unattended installs and have reproduced the issue and see what you mean.
This is how I call scripts passing parameters:
This is the CreateDatabase.sql script file:
So you dont need to use GO when creating a database.
When creating the schema and populating your database I would suggest using SQL tools to export the script so you end up with scripts that look like this: