SSIS and Sql Server Journey

Personal Notes of Sarabjit Singh and Bhavpreet Singh

Sql Server 2008,2012: Run Sql Script File From Command Line

on April 1, 2013

To Start Sql Command reform following link:
http://msdn.microsoft.com/en-us/library/ms166559(v=sql.105).aspx

Run the following command in the command prompt.

Replace “C:\myScript.sql” with the location of your sql code file location.

 sqlcmd -S myServer\instanceName -i C:\myScript.sql

The above command will return the result set in command prompt.

If you prefer the result in a text file use the code below:

 sqlcmd -S myServer\instanceName -i C:\myScript.sql -o C:\EmpAdds.txt

Happy Coding 🙂

Advertisements

One response to “Sql Server 2008,2012: Run Sql Script File From Command Line

  1. Remarkable! Its really awesome post, I have got much clear idea about
    from this paragraph.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: