SQL Server
SQL Server is a relational database management system created by Microsoft and uses ANSI SQL as standard query language.SQL, or Structured Query Language. It uses SQL statements to store, manipulate, retrieve, and manage data in a database.
Types of SQL statements
In SQL Server, SQL Statements are divided into four categories,
- DML(Data Manipulation Language) - Select, Insert, Update, Delete
- DDL(Data Definition Language) - Create, Drop, Alter
- DCL(Data Control Language) - Grant, Revoke
- TCL(Transaction Control Language) - Begin, Tran, Commit, Rollback.
Introduction
In this article, we will learn how to use different SQL statements to create objects such as tables, views, stored procedures, and functions(system and user-defined) in a database and how to use the objects to store and manipulate data.
This step-by-step guide will explain how to use the SQL Server Management Studio tool to execute various SQL statements.
Step 1
Assuming you've SQL Server 2012 or higher version.
Open Sql Server Management Studio. After connecting, open a New Query Window.

Step 2
In the New Query Window, start writing and executing SQL queries. Before anything else, we must create a database. To create one, follow the following steps.
Database
A database is an organized collection of data and objects (tables, views, procedures, functions, etc.), generally stored and accessed electronically from a computer system.
Create a database,
Create database LearningBasicSQL
Tables in SQL Server
Tables are database objects that contain all the data in a database. In tables, data is logically organized in a row-and-column format similar to a spreadsheet. Each row represents a unique record, and each column represents a field in the record. Each row in a relational database is known as a tuple.
To find a detailed article about the Tables in SQL, please go through this: Tables in SQL
Create a table,
use LearningBasicSQL
create table tbl_Employee(
EmpID int primary key not null identity(1,1),
EmpName varchar(50),
City varchar(20)
)
Insert values in a table,
insert into tbl_Employee values('Shilpa','Kolkata'),('Sayantan','Howrah')
Get rows of a table,
select * from tbl_Employee
Insert values in a table using Insert Into Select statement,
insert into tbl_Employee (EmpName,City)
select 'Anuja','Siliguri'
Delete a row from a table,
delete from tbl_Employee where EmpID=4
Truncate a table,
truncate table tbl_Employee
Drop a table,
drop table tbl_Employee
Stored Procedure in SQL
A stored procedure is a subroutine available to applications that access a relational database management system. Such procedures are stored in the database data dictionary. To find a detailed article about the stored procedure, please go through this: Stored Procedure. The following queries will help you create, update, and delete store procedures.
Create a stored procedure for add/update,
create procedure sp_AddEditEmployee (
@EmpId int=0,
@EmpName varchar(50),
@City varchar(20),
@Mode int
)
as
begin
if @Mode=0
insert into tbl_Employee values(@EmpName,@City )
if @Mode=1
update tbl_Employee set EmpName=@EmpName,City=@City where EmpID=@EmpId
end 
Rajanikant HawaldarPosted Jul 23, 2019, 4:02 AM
Tbl Employee should be tbl_Employee
Vinay Kumar GuptaPosted Jun 12, 2019, 12:58 PM
Could you please brief with some of the advanced scenarios to cover point 2 and 3.