Introduction
https://github.com/microsoft/sql-server-samples/tree/master/samples/databases
Before you begin
To run this sample, you need a tool that can run Transact-SQL scripts. You can run the scripts in the following tools:
- SQL Server Management Studio (SSMS). To download SSMS, go to Download SQL Server Management Studio (SSMS).
- QL Server Data Tools (SSDT) or Visual Studio. To download SSDT, or to enable its features in Visual Studio, go to Download and install SQL Server Data Tools (SSDT) for Visual Studio.
Run the scripts in SSMS
- Open SSMS.
- Connect to the target SQL Server.
- Open the script in a new query window.
- Run the script.
Run the scripts in SSDT or Visual Studio
- Open SSDT or Visual Studio.
- Open the SQL Server Object Explorer.
- Connect to the target SQL Server.
- Open the script in a new query window.
- Run the script.
OR
You can create a database by running the below query if you have trouble with the above methods.
Create a database in SQL SERVER
The following SQL statement creates a database called “Northwind":
Example
- CREATE DATABASE Northwind;
The following example creates a table called "Customers" that contains eleven columns:
- USE [Northwind]
- GO
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- 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,
- CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED
- (
- [CustomerID] ASC
- )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
- ) ON [PRIMARY]
- GO
INSERT INTO Example
The following SQL statement inserts a new record in the "Customers" table:
- INSERT [dbo].[Customers] ([CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax]) VALUES (N'ALFKI', N'Alfreds Futterkiste', N'Maria Anders', N'Sales Representative', N'Obere Str. 57', N'Berlin', NULL, N'12209', N'Germany', N'030-0074321', N'030-0076545')
- INSERT [dbo].[Customers] ([CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax]) VALUES (N'ANATR', N'Ana Trujillo Emparedados y helados', N'Ana Trujillo', N'Owner', N'Avda. de la Constitución 2222', N'México D.F.', NULL, N'05021', N'Mexico', N'(5) 555-4729', N'(5) 555-3745')
- INSERT [dbo].[Customers] ([CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax]) VALUES (N'ANTON', N'Antonio Moreno Taquería', N'Antonio Moreno', N'Owner', N'Mataderos 2312', N'México D.F.', NULL, N'05023', N'Mexico', N'(5) 555-3932', NULL)
- INSERT [dbo].[Customers] ([CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax]) VALUES (N'AROUT', N'Around the Horn', N'Thomas Hardy', N'Sales Representative', N'120 Hanover Sq.', N'London', NULL, N'WA1 1DP', N'UK', N'(171) 555-7788', N'(171) 555-6750')


Sourav Kumar DasPosted Nov 19, 2019, 10:58 PM
Keep it on..
Sourav Kumar DasPosted Nov 19, 2019, 10:35 PM
Nice useful article for basics.