4. Introduction
SQL server is a relational database management system
Editions include
Express (Free)
Developer (Free – for testing and development )
Standard (License – Production )
Enterprise (License – Production )
5. What is Database & DBMS ?
There are two types of dbms
Relational Non-
Relational
A DBMS is a program which enables its users to access database, manipulate
data,
reporting / representation of data
6. Relational database management system
Empid Ename Doj Deptno Salar
y
101 John 10 15020
102 Thomas 20 23495
Deptno Dname Location
10 Accounts
20 IT
Employee Department
What is RDBMS ?
7. `
What is SQL & T-SQL ?
SQL is a standard language for storing, manipulating, and retrieving data in
databases
SQL
SQL Server
Select * from products;
Transact - SQL is an extension of the SQL Languages
15. What is a data type ?
Numeric
String
Date and Time
Binary
Miscellaneous
Type of data a variable can store
16. Numeric Data types
Numeric
Integer
Bigint, Int, Smallint,
TinyInt,Bit
Decimal
Decimal, Money,
SmallMoney, Numeric
For example
Even within the integer category, these are host of integer data types are
available
17. Data Types
Category Data
Type
From To
Number Int -2147483648 2147483647
Number Bit 0 1
Number Decimal -10^38 + 1 10^38-1
Date Datetime Jan 1, 1753 Dec 31,9999
String Char Char Max len of 8000 characters(fixed
length Unicode char)
String Varchar Varchar Max len of 8000 characters
Binary Max length of 8000 byes (fixed length binary data
19. String - built-in functions
ABS
ROUND
CEILING
FLOOR
COUNT
MIN
MAX
SUM
EXP
POWER
ISNUMERIC
20. String - built-in functions
ABS
ROUND
CEILING
FLOOR
COUNT
MIN
MAX
SUM
EXP
POWER
ISNUMERIC
21. Date - built-in functions
CURRENT_TIMESTAMP
DATEADD
DATEDIFF
DATEFROMPARTS
DATENAME
DATEPART
DAY
GETDATE
GETUTCDATE
ISDATE
MONTH
SYSDATETIME
YEAR
22. Date Type functions
SELECT DATEPART (YEAR, GETDATE()) AS [Year],
DATEPART (QUARTER, GETDATE()) AS [Quarter],
DATEPART (MONTH, GETDATE()) AS [Month],
DATEPART (DayOfYear, GETDATE()) AS [DayOfYear],
DATEPART (DAY, GETDATE()) AS [Day],
DATEPART (WEEK, GETDATE()) AS [Week],
DATEPART (WEEKDAY, GETDATE()) AS [Weekday],
DATEPART (HOUR, GETDATE()) AS [Hour],
DATEPART (MINUTE, GETDATE()) AS [Minute],
DATEPART (SECOND, GETDATE()) AS [Second],
DATEPART (MILLISECOND, GETDATE()) AS [Millisecond],
DATEPART (MICROSECOND, GETDATE()) AS [Microsecond],
DATEPART (NANOSECOND, GETDATE()) AS [NanoSecond],
DATEPART (ISO_WEEK, GETDATE()) AS [ISO Week]
29. `
What and why of Constraints ?
Constraints are the rules enforced on the data columns of a
table
SQL NOT NULL
UNIQUE
PRIMARY KEY
FOREIGN KEY
CHECK
DEFAULT
32. `
Types of Joins
Constraints are the rules enforced on the data columns of a table
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL JOIN
SELF JOIN
CARTESIAN JOIN
38. Rounding Functions
Aggregation
Functions
Logical Functions
A ready to use data in SQL Server
table
1
2
Prerequisites
SQL Server and SSMS installed