I have developed a C# application connecting to a SQL Server database. I now wish to test the application on the client PC, and so I scripted the database and now wish to deploy it on the client PC.
The client PC is running SQL Server Express, however SQL Server Management Studio is not installed and so I thought I would use SqlCmd
to execute the script on the local server of the PC. Note: when I installed SQL Server Express I set the instance name to MSSQLSERVER
.
The problem I'm having is with the command I'm typing :
-S SomePCName\MSSQLSERVER -i C:\CreateDBSql.sql
When I run the command, I get the following message:
What am I doing wrong?
The problem mainly appears to be that you are not running SQLCMD correctly. Command-line parameters (or "flags" or "switches") need to be entered on the, well, command line ;-). Try the following (note the use of
(local)
):UPDATE:
It seems that since MSSQLSERVER is the default "default instance" name, it is reserved and cannot be used in a connection string explicitly. In this case you can try the following:
If that doesn't work, then it might be best to reinstall SQL Server Express while using a different instance name: either the preferred default instance name for SQL Server Express (i.e.
SQLExpress
) or something that is neitherSQLExpress
norMSSQLSERVER
.