Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
SQL Azure - Import Scripts in Azure Portal
WhatsApp
Karthikeyan Anbarasan
13y
9.2k
0
1
100
Article
Introduction:
In this article we are going to see how to do import database scripts available in SQL Azure Management Portal.
Overview:
We have seen in our earlier articles how to manage a database by creating tables, views and stored procedures directly in the Azure portal; now we are going to see the options available to import existing available scripts to run on the Azure portal.
In a traditional SQL Server locally we will create all the scripts and run the required scripts on the server based on the needs, in a similar manner we can import the whole script to the Azure portal and use it as needed. Let us see the procedure for importing using the Azure portal step by step.
Steps:
Log in to the Azure portal using the below link. You wll see the screen look similar to below.
http://www.microsoft.com/windowsazure/
Login to the portal using your Microsoft Windows Live credentials with Azure credentials to the Management Portal and you will see the screen as shown in the screen below:
Now we can see the Database Menu at the bottom left; clicking on that will go to the Database Subscription window as shown in the screen below:
Clicking on the subscription name will provide the complete details of the server created and the new database created as shown in the screen below:
Now we are going to create a new database using some scripts we prepared locally. In our sample we have scripts to create a small table, a view and a stored procedure to import to the Azure database.
Script:
CREATE TABLE [dbo].[Employees](
[EmployeeID] [int] IDENTITY(1,1) NOT NULL,
[LastName] [nvarchar](20) NOT NULL,
[FirstName] [nvarchar](10) NOT NULL,
[Title] [nvarchar](30) NULL,
[TitleOfCourtesy] [nvarchar](25) NULL,
[BirthDate] [datetime] NULL,
[HireDate] [datetime] NULL,
[Address] [nvarchar](60) NULL,
[City] [nvarchar](15) NULL,
[Region] [nvarchar](15) NULL,
[PostalCode] [nvarchar](10) NULL,
[Country] [nvarchar](15) NULL,
[HomePhone] [nvarchar](24) NULL,
[Extension] [nvarchar](4) NULL,
[Photo] [image] NULL,
[Notes] [ntext] NULL,
[ReportsTo] [int] NULL,
[PhotoPath] [nvarchar](255) NULL
)
CREATE TABLE [dbo].[Customers](
[CustomerID] [nchar](5) NOT NULL,
[CompanyName] [nvarchar](40) NOT NULL,
[ContactName] [nvarchar](30) NULL,
[ContactTitle] [nvarchar](30) NULL,
[Address] [nvarchar](60) NULL,
[City] [nvarchar](15) NULL,
[Region] [nvarchar](15) NULL,
[PostalCode] [nvarchar](10) NULL,
[Country] [nvarchar](15) NULL,
[Phone] [nvarchar](24) NULL,
[Fax] [nvarchar](24) NULL
)
CREATE TABLE [dbo].[Products](
[ProductID] [int] IDENTITY(1,1) NOT NULL,
[ProductName] [nvarchar](40) NOT NULL,
[SupplierID] [int] NULL,
[CategoryID] [int] NULL,
[QuantityPerUnit] [nvarchar](20) NULL,
[UnitPrice] [money] NULL ,
[UnitsInStock] [smallint] NULL,
[UnitsOnOrder] [smallint] NULL ,
[ReorderLevel] [smallint] NULL ,
[Discontinued] [bit] NOT NULL
)
Create view [dbo].[Current Product List] AS
SELECT Product_List.ProductID, Product_List.ProductName
FROM Products AS Product_List
WHERE (((Product_List.Discontinued)=0))
Once we are ready with the script we will save it in a file Database Script.sql and now we are ready to do an import.
Now let us create a database. (Check my earlier article on how to create a database in SQL Azure portal.) Once the database is created your screen will look like below:
Now go to the Manage portal by clicking on the Manage button on the top menu as shown in the screen below:
Now we are prompted to enter the credentials to login to the server as shown in the screen below. Doing this is something like when we enter SQL Server Management Studio we are asked to enter the login credentials.
Once we entered valid credentials our page will look like below with the new SQL Azure Management Portal:
Now we have a script ready to import to the SQL Azure database; we can do that by going to the OPEN QUERY window as shown in the screen below:
Now it will open the window to select the file as shown in the screen below:
Select the file and click on Open to open the scripts in the Azure portal window as shown in the screen below:
Now Select the appropriate tables and click on the Execute button at the top to execute the table, views and stored procedures separately. Else if we have scripts arranged in the correct order we can execute them as a whole as shown in the screen below:
Now we can see the commands are executed correctly. We can check the new tables by going to each section menu at the left side as shown in the screen below.
Before doing that we need to click on the refresh button in order to refresh the Schema and get the latest changes as shown in the screen below:
Now we can see the new tables and the views added in the list as shown in the screen below:
Conclusion:
So in this article we have seen how to do an import database script option using SQL Azure Management Portal.
.net
Azure
Azure portal
C#
how to Import Scripts in Azure portal
import scripts
Import Scripts in Azure portal
SQL Azure
SQL Azure management portal
windows Azure
Up Next
Ebook Download
View all
Understanding Azure : A Beginner’s Guide
Read by 8.4k people
Download Now!
Learn
View all
Membership not found