Earlier In Task, we learned how to create a basic stored procedure. In this post, we are going to create a database via TSQL command.
Trying out how to create databases via TSQL command is important to new users because:
- Creating Databases in Azure environment is little different. Since you do not worry about the hardware and you do not worry about the location the database files – options for specifying location of mdf/ldf file, specifying filegrowth of mdf/ldf, etc are not available.
- As a new user, you might have created a database via Azure portal – But what we wish to do instead is create a Database via TSQL command.
So Let’s explore couple of TSQL commands to create sql azure database. You can connect to SQL Azure master database via SSMS and run these queries. You can also connect to the Master Database in a SQL Azure server via the portal and run these queries. Either ways, since our focus to write TSQL commands – we’ll not go into the details on how to connect to SQL Azure – I’ll leave it up to you to choose the tooling. And once you are logged and ready to run TSQL command, Here are couple of TSQL Queries to play with:
Note: You may be charged if you execute the queries shown below. Just wanted to let you know that before you decide to execute them.
1. Following TSQL Command would create a SQL Azure Database with Edition = “Web” and Max Size = “1 GB”.
[sourcecode language=”sql”] create database [/sourcecode]
2. Following TSQL command shows how you can specify the edition of the SQL Azure database and the Max size.
[sourcecode language=”sql”] CREATE DATABASE University (MAXSIZE=20GB , EDITION=’business’) [/sourcecode]
Here the MaxSize could take the values from 1 or 5 (for web edition database) then 10,20,30….150
And the edition value can either be web or business.
That’s about it for this post. But do not forget that you could be charged when you are playing with these queries. And here are few resources for you:
Managing Databases and Logins
TSQL: Create Database
And Let’s connect! I Look forward to Interacting with you on any of these people networks: