Azure – How to create an Azure SQL Database

By | 05/06/2020

In this post, we will see how to create an Azure SQL Database using the Azure portal.

We open a browser, go to https://portal.azure.com, select “Create a resource” and we choose “SQL Database”:

The first things we have to set are:
Resource Group
Database Name
Server

Then, we have to set some Networking parameters:

Finally, we review everything and then we push the button “Create”:

When the Azure SQL Server is ready, we will see a message like that:

Now, in order to manage the database, we select the item “Query editor” and then we insert Login and Password:

Here, we can run sql script DDL (Data Definition Language), DQL (Data Query Language) or DML (Data Manipulation Language).
Now, we will create a table called TabUser (DDL), we will insert some data (DML) and finally we will run a select in order to very that everything worked fine (DQL).

CREATE TABLE

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TabUser](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
	[DateCreation] [datetime] NOT NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

INSERT DATA

SET IDENTITY_INSERT [dbo].[TabUser] ON 
GO
INSERT [dbo].[TabUser] ([Id], [UserName], [Password], [DateCreation]) VALUES (1, N'Username10', N'Password10', CAST(N'2020-04-15T23:25:39.873' AS DateTime))
GO
INSERT [dbo].[TabUser] ([Id], [UserName], [Password], [DateCreation]) VALUES (2, N'Username11', N'Password11', CAST(N'2020-04-14T23:26:32.013' AS DateTime))
GO
INSERT [dbo].[TabUser] ([Id], [UserName], [Password], [DateCreation]) VALUES (3, N'Username12', N'Password12', CAST(N'2020-04-13T23:30:16.103' AS DateTime))
GO
INSERT [dbo].[TabUser] ([Id], [UserName], [Password], [DateCreation]) VALUES (4, N'Username13', N'Password13', CAST(N'2020-04-13T23:30:16.107' AS DateTime))
GO
INSERT [dbo].[TabUser] ([Id], [UserName], [Password], [DateCreation]) VALUES (5, N'Username14', N'Password14', CAST(N'2020-04-12T23:30:16.107' AS DateTime))
GO
INSERT [dbo].[TabUser] ([Id], [UserName], [Password], [DateCreation]) VALUES (6, N'Username15', N'Password15', CAST(N'2020-04-13T23:30:16.107' AS DateTime))
GO
INSERT [dbo].[TabUser] ([Id], [UserName], [Password], [DateCreation]) VALUES (7, N'Username16', N'Password16', CAST(N'2020-04-10T23:30:16.107' AS DateTime))
GO
INSERT [dbo].[TabUser] ([Id], [UserName], [Password], [DateCreation]) VALUES (8, N'Username17', N'Password17', CAST(N'2020-04-07T23:30:16.107' AS DateTime))
GO
INSERT [dbo].[TabUser] ([Id], [UserName], [Password], [DateCreation]) VALUES (9, N'Username18', N'Password18', CAST(N'2020-03-25T23:30:16.110' AS DateTime))
GO
SET IDENTITY_INSERT [dbo].[TabUser] OFF
GO

SELECT DATA

select Id, UserName, Password, DateCreation from [dbo].[TabUser] order by Id






Leave a Reply

Your email address will not be published.