diTii.com Digital News Hub

Sign up with your email address to be the first to know about latest news and more.

I agree to have my personal information transfered to MailChimp (more information)


SQL Azure: Creating & dropping a database with SQLCMD

Once you’ve your server allocated via SQL Azure Portal you can create and drop databases from your desktop’s command line using sqlcmd.exe. This can be handy for clean slate testing where you want to create a database from scratch, unload a schema and then do some testing in a repeatable way.

First, you need to construct a .sql file that contain Transact-SQL command to create your database, it looks: CREATE DATABASE Test. This’ll create you a 1 GigaByte database, default size. There should be no other Transact-SQL statements in this .sql file. More on MSDN.

To execute from command line where file is named CreateDatabase.sql, use this command: sqlcmd -SyourSeverdatabase.windows.net [email protected] -PyourPassword -dmaster -i –N CreateDatabase.sql. “user name needs to be in the form: [email protected], where login is the admin login for server on SQL Azure. You can get this information directly from SQL Azure portal. Notice that database targeted is master.

Dropping a database looks like: DROP DATABASE Test. More on MSDN. To execute from command line where file is named DropDatabase.sql, use this command: sqlcmd -SyourSeverdatabase.windows.net [email protected] -PyourPassword -dmaster -i –N DropDatabase.sql.


Share This Story, Choose Your Platform!

Get Latest News

Subscribe to Digital News Hub

Get our daily newsletter about the latest news in the industry.
First Name
Last Name
Email address
Secure and Spam free...