SQL SERVER BASIC 1 Training
SQL SERVER BASIC 1 Training
BY CHRIST KANKEU
Overview
a. Introduction
• What is SQL Server
• History SQL Server
• SQL Server Edition
• Importance of SQL Server Instance
• Summary
b. SQL Server Database : Create, Alter, Drop, Backup /
Restore
c. SQL Server Data Types
SQL Server
d. SQL Server Table: CREATE, ALTER, DROP
e. SQL Server DML (Insert, Update, Delete)
f. SQL Server Keys, Constraints and Indexes
a. Introduction
• What is SQL Server ? • Version History SQL Server
SQL SERVER is a relational database management Microsoft and Sybase released version 1.0 in 1989.
system (RDBMS) developed by Microsoft. It is primarily
designed and developed to compete with MySQL and However, the partnership between these two
Oracle database. ended in the early 1990s.
SQL Server supports ANSI SQL, which is the standard Microsoft maintained ownership rights to the
SQL (Structured Query Language) language. However, name SQL Server.
SQL Server comes with its own implementation of the
SQL language, T-SQL (Transact-SQL). Since the 1990s, subsequent versions of SQL
T-SQL is a Microsoft propriety Language known
Server have been released including SQL Server
as Transact-SQL. It provides further capabilities of 2000, 2005, 2008, 2012, 2014, 2016, 2017, and
declaring variable, exception handling, stored 2019
procedure, etc.
a. Introduction - Conts
• SQL Server Editions • Importance of SQL Server
SQL Server Enterprise: It is used in the high end, large Instances
scale and mission Critical business. It provides High-end
security, Advanced Analytics, Machine Learning, etc. The following are the advantages of SQL Server
SQL Server Standard: It is suitable for Mid-Tier instances:
Application and Data marts. It includes basic reporting and 1. For installation of different versions on one
analytics. machine
SQL Server WEB: It is designed for a low total-cost-of- 2. For cost reduction
ownership option for Web hosters. It provides scalability,
3. For maintenance of development, production and
affordability, and manageability capabilities for small to
test environments separately
large scale Web properties.
4. For reducing temporary database problems
SQL Server Developer: It is similar to an enterprise
edition for the non-production environment. It is mainly 5. For separating security privileges
used for build, test, and demo. 6. For maintaining a standby server
SQL Server Express: It is for small scale applications and
free to use.
a. Introduction - Conts
• Summary
• SQL Server is defined as a relational database management system (RDBMS) developed by
Microsoft
• Various Editions of SQL Server are Enterprise, Standard, Web, Developer, and Express
• You can run multiple instances of SQL Server the same on the same machine.
b. SQL Server Database
a. Connect to SQL Server Next, from the Connect menu under
First, launch the Microsoft SQL Server the Object Explorer, choose the Database
Management Studio from the Start menu Engine…
[1]
[2]
b. SQL Server Database - Conts
If the connection is established successfully,
then you will see the following Object
Explorer panel:
[3]
[4]
b. SQL Server Database - Conts
1. SQL Server Management Studio
b. Create Database
There are 2 ways to create Database in SQL
server.
1. SQL Server Management Studio
2. Transact-SQL
[1.1]
b. SQL Server Database - Conts
[1.2]
b. SQL Server Database - Conts
[1.3]
Syntax:
CREATE DATABASE <Database_name>
Query:
CREATE DATABASE [2.1]
[Edu_TSQL_file]
[2.3]
[2.2]
b. SQL Server Database - Conts
1. SQL Server Management Studio
c. Alter Database
There are 2 ways to alter Database in SQL
server.
1.SQL Server Management Studio
2.Transact-SQL
b. SQL Server Database - Conts
2. Transact-SQL
Syntax:
ALTER DATABASE <Databse_name> MODIFY
NAME = <New Name>
Query:
ALTER DATABASE <Databse_name> MODIFY NAME =
<New Name>
b. SQL Server Database - Conts
1.SQL Server Management Studio
d. Delete Database
Syntax:
DROP DATABASE <Databse_name>
Query:
USE master; GO DROP DATABASE
Edu_TSQL_Alter; GO
b. SQL Server Database - Conts
e. Backup /
Restore Database
c. SQL
Server
Data
Type
Example :
DECLARE @Datatype_Char VARCHAR(30) = 'This is
Character Datatype' PRINT @Datatype_Char
Syntax:
SELECT (Column 1, …) INTO <New Table name>
FROM <Old Table name>;
Query:
SELECT COURSE_NAME INTO COURSE_NAMES
FROM COURSE;
d. SQL Server Table - Conts
b. Alter Table 2. Using Table designer
There are two ways to Alter Table in SQL server.
1. T-SQL: Alter Table by adding new columns.
2. Using Table designer
Example:
ALTER TABLE dbo.Course_Title ADD Course_Duration
VARCHAR(20);
d. SQL Server Table - Conts
1. Using SQL Server Management Studio.
c. Drop Table
Constraint Example:
Example :
[2]
SQL Server Management Studio
[5]
[7] [8]
[9]
f. SQL Server : Keys, Constraint,
Indexes - Conts
• Foreign Key
Syntax:
Query:
CREATE TABLE Course_Strength_TSQL ( Course_ID Int,
Course_Strength Varchar(20) CONSTRAINT FK FOREIGN
KEY (Course_ID) REFERENCES COURSE (Course_ID) )
ALTER TABLE employees ADD CONSTRAINT ALTER TABLE employees ADD CONSTRAINT check_last_name CHECK
employees_unique UNIQUE (employee_number); (last_name IN ('Smith', 'Anderson', 'Jones'));