时间:2021-07-01 10:21:17 帮助过:2人阅读
Now that our example is set, we will execute the CreateDBCompany.sql script file using SQLCMD command line.
1. Click Run and type the letters CMD . Hit OK , and a command prompt window will appear.
2. Now, locate the directory C:\sqlscripts\ using the following commands:
• Change the directory to C drive using cd c:\ .
• Go to the folder by typing cd followed by a space, and then sqlscripts folder name such as cd sqlscripts .
• See the sqlscripts directory contents using dir . You can see our CreateDBCompany.sql file.
3. Here, we are using SQLCMD to connect to your local sql server database. Through this same process you may connect to any remote sql server on your network.
SQLCMD -S DALVI2\SQLSERVER2012 -E -i CreateDBCompany.sql
The -S switch is for the Server name and is the same one we use to connect using SSMS GUI. Connect to server option. In my case, it is DALVI2\SQLSERVER2012 .
The -E switch is used for trusted connection.
The -i switch is for .sql script file name.
You should now be able to go to SSMS and query the DBCompany database. You will see the employee table with the one record that we had previously created
SQLCMD
标签: