I’ve seen several questions on forums over whether or not you can use SQLCMD with your SQL Azure instance. Well, I’m here to say yes you can! You can even create databases using the command line.
Create a .sql file with a script that creates your database, then save the file.
CREATE DATABASE databaseName
Then drop back to command line and use the following command:
sqlcmd -SyourInstanceName.windows.net -Uyou@domain.com -PyourPassword -dmaster -i –N CreateDatabase.sql
The server is whatever your SQL Azure instance name is, your login and password should be the login and password you have set up to access your Azure instance. I would like you to notice you’re connecting to the master database, just as you would in a local SQL instance. Run this command, and you have your database. If you wanted to drop a database, just change out the script file to one that points to a DROP DATABASE command.
If you want to run any other script from SQLCMD, just make sure you update master to the database that that contains the objects you’re going to reference in your script. Just remember, you cannot use GO databaseName with SQL Azure. Pretty easy stuff, right?
If you have any questions or concerns with SQL command and SQL Azure, let me know! I’m here to help!