Saturday, April 27, 2013

How to execute Sql Script using Command prompt




E:\>sqlcmd -ddbname –S.\SqlExpress -Usa -PWelcome123 -iScript.sql

The above command script for Sql Server login authentication

1    1)      You have to copy the Sql Script file to any drive. Here I have used E drive.
2    2)      In the command prompt you have to select the drive where you have copied the script file.
3    3)      Before execute the script you have to create the new database.  Here I have created dbname as Database name.
4    4)      dbname  is the Database name.
5    5)      .\SqlExpress  is the Sql server instance name.
6    6)      sa is the username of the Sql Server.
7    7)      Welcome123 is the password of the Sql Server.
8    8)      Script.sql is the Script file.

No comments:

Post a Comment