未加星标

Creating New SQL Database And Table With Azure

字体大小 | |
[系统(windows) 所属分类 系统(windows) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

Introduction

In this article, we will see in detail about how to create our first SQL Server database in Azure and creating a table for Azure SQL database from our SQL Server Management Studio.

Prerequisites

Azure Account: If you don’t have free account, you can create from this link . SQL Server 2014 or above.

Create new SQL Database on Azure

Using your Azure account, login to Azure site. From the dashboard page on the left side menu, we can see SQL databases. Click menu to create our first SQL database in Azure.
Creating New SQL Database And Table With Azure

We can see the Add icon at the top. To create our fist SQL database, again click Add icon.


Creating New SQL Database And Table With Azure

Here, we give our new database name and select or create our resource group.


Creating New SQL Database And Table With Azure

Creating SQL Server on Azure

If we don’t have any SQL Server created, first we need to create a new SQL Server to create our database.

Here, we give our new Server name, login ID and Password for login to our Azure SQL Server.


Creating New SQL Database And Table With Azure

Once our Server was created, select the newly added SQL Server to create our database.


Creating New SQL Database And Table With Azure

Click Create button at the bottom to create our new database on the selected Server. Now, we can see a confirmation message as Validation Successful.


Creating New SQL Database And Table With Azure

We can see now our new database has been created.


Creating New SQL Database And Table With Azure

We can see all the details for newly created database from the database dashboard page.


Creating New SQL Database And Table With Azure

To know our Azure SQL connection, we can click on the “Show database connection strings”. We can see the connection string for ADO.NET, ODBC,php and JDBC. We can use this connection string in our technology Applications to connect Azure databases. For example, to work with Microsoft.NET, we can select ADO.NET for working with JSP or Java, we can use JDBC or ODBC and to work with PHP Application, we can use the PHP connection strings.


Creating New SQL Database And Table With Azure

Connecting Azure SQL Serve from Local SQL Server

Now, we have created our SQL database in Azure. To create tables and insert sample records, we will use SQL Server Management studio to connect to our Azure Server.

We need to give our Azure SQL Server name with our given ID and password.


Creating New SQL Database And Table With Azure

When we try to connect for the first time, we may get the error, as shown below-


Creating New SQL Database And Table With Azure

This error is due to the Firewall rule, which is not set by the selected Azure Server.

Setting Azure SQL Server firewall rule

You can find “Set server Firewall” at the top. Click to set our Firewall rule.
Creating New SQL Database And Table With Azure

Click “Add Client IP” to set our new Firewall rule.


Creating New SQL Database And Table With Azure

Click save to add our new Firewall Setting


Creating New SQL Database And Table With Azure

After saving the new Firewall setting, now again connect to our Azure SQL Server from our local SQL Server Management Studio.


Creating New SQL Database And Table With Azure

Creating Tables for Azure SQL Database

Now, we have connected our Azure SQL Server. Let’s create tables and insert record in our Azure database.

In Query Analyzer, run Create SQL script to create our tables, which is given below.

IFEXISTS(SELECT[name]FROMsys.tablesWHERE[name]='HotelMaster') DROPTABLEHotelMaster GO CREATETABLEHotelMaster ( RoomIDintidentity(1,1), RoomNoVARCHAR(100)NOTNULL, RoomTypeVARCHAR(100)NOTNULL, PrizeVARCHAR(100)NOTNULL CONSTRAINT[PK_HotelMaster]PRIMARYKEYCLUSTERED ( RoomIDASC )WITH(PAD_INDEX=OFF,STATISTICS_NORECOMPUTE=OFF,IGNORE_DUP_KEY=OFF,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON)ON[PRIMARY] )ON[PRIMARY] InsertintoHotelMaster(RoomNo,RoomType,Prize)Values('101','Single','50$') InsertintoHotelMaster(RoomNo,RoomType,Prize)Values('102','Double','80$') select*fromHotelMaster IFEXISTS(SELECT[name]FROMsys.tablesWHERE[name]='RoomBooking') DROPTABLERoomBooking GO CREATETABLERoomBooking ( BookingIDintidentity(1,1), RoomIDint, BookedDateFRVARCHAR(20)NOTNULL, BookedDateTOVARCHAR(20)NOTNULL, BookingStatusVARCHAR(100)NOTNULL, PaymentStatusVARCHAR(100)NOTNULL, AdvancePayedVARCHAR(100)NOTNULL, TotalAmountPayedVARCHAR(100)NOTNULL, CONSTRAINT[PK_RoomBooking]PRIMARYKEYCLUSTERED ( [BookingID]ASC )WITH(PAD_INDEX=OFF,STATISTICS_NORECOMPUTE=OFF,IGNORE_DUP_KEY=OFF,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON)ON[PRIMARY] )ON[PRIMARY] select*fromRoomBooking Now, we can see our new tables have been created in Azure SQL database.
Creating New SQL Database And Table With Azure

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

主题: SQLPHPSQL ServerJavaJSPRIMRYTIUTDU
分页:12
转载请注明
本文标题:Creating New SQL Database And Table With Azure
本站链接:http://www.codesec.net/view/482948.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(22)