Saturday, April 25, 2015

Running SQL Server script from the command-line

Have you ever needed to run a Transact-SQL script of 1 or 2GB into your SQL Server? Well that happened to me yesterday.

Normally I work with machines with enough resources to open such files, so I'm able to create the databases on SQL Server using the Management Studio. But since last week I've been working on a MacMini with just 4GB of memory, what to do when you need to open a 2GB SQL file into Management Studio? Well go do something else, because it's going to take some time.

Today I found a very elegant way to do it, using the utility SQLCMD.

Using this tool, available in your path if you have SQL Server installed, all you need to do is:
  • Open a command prompt window.
  • In the Command Prompt window, type: sqlcmd -S myServer\instanceName -i C:\myScript.sql
  • Press ENTER.
That's all folks, have fun! P.S: SQL Server 2014 Rocks!

1 comment :

  1. Bet365 Casino & Promos 2021 - JTM Hub
    Full list www.jtmhub.com of Bet365 Casino & Promos · Up to £100 communitykhabar in Bet Credits gri-go.com for new customers at bet365. Min deposit £5. Bet Credits available for use upon settlement of https://deccasino.com/review/merit-casino/ bets to https://vannienailor4166blog.blogspot.com/ value of

    ReplyDelete