3
0 Microsoft SQL Server Overview
Installation and Configuration of SQL Server & SSMS
Data Types
Built-in Functions
5
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 )
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
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 ?
`
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
Microsoft SQL Server
SQL Server management studio
25
What is a data type ?
Numeric
String
Date and Time
Binary
Miscellaneous
Type of data a variable can store
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
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
Numeric built-in functions
ABS
ROUND
CEILING
FLOOR
COUNT
MIN
MAX
SUM
EXP
POWER
ISNUMERIC
String - built-in functions
ABS
ROUND
CEILING
FLOOR
COUNT
MIN
MAX
SUM
EXP
POWER
ISNUMERIC
String - built-in functions
ABS
ROUND
CEILING
FLOOR
COUNT
MIN
MAX
SUM
EXP
POWER
ISNUMERIC
Date - built-in functions
CURRENT_TIMESTAMP
DATEADD
DATEDIFF
DATEFROMPARTS
DATENAME
DATEPART
DAY
GETDATE
GETUTCDATE
ISDATE
MONTH
SYSDATETIME
YEAR
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]
OPERATORS
 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators
 String operators
 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators
 Arithmetic operators
 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators
 Comparison operators
 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators
 Logical operators
AND
OR
NOT
LIKE
BETWEE
N
IN
Constraints
`
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
`
Primary key, Unique Key, & Foreign key
Empi
d
Ename Project
#
Deptno Salary Phone #
101 John WMDM 10 15020 932-001-
4739
102 Thoma
s
HCDW 20 23495
103 Rajesh SCAS 10 148292
Deptno Dname Location
10 Accounts
20 IT
Employee
Department
Primary Key
Foreign Key
Primary Key
Unique Key
JOINS
`
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
How to drop sql server
How to drop a sql database
93
 Rounding Functions
 Aggregation
Functions
 Logical Functions
A ready to use data in SQL Server
table
1
2
Prerequisites
SQL Server and SSMS installed

SQL Server part 1 (6).pptx

  • 1.
  • 2.
    0 Microsoft SQLServer Overview Installation and Configuration of SQL Server & SSMS Data Types Built-in Functions
  • 3.
  • 4.
    Introduction SQL server isa 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 managementsystem 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
  • 8.
    Microsoft SQL Server SQLServer management studio
  • 14.
  • 15.
    What is adata 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 FromTo 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
  • 18.
  • 19.
    String - built-infunctions ABS ROUND CEILING FLOOR COUNT MIN MAX SUM EXP POWER ISNUMERIC
  • 20.
    String - built-infunctions ABS ROUND CEILING FLOOR COUNT MIN MAX SUM EXP POWER ISNUMERIC
  • 21.
    Date - built-infunctions CURRENT_TIMESTAMP DATEADD DATEDIFF DATEFROMPARTS DATENAME DATEPART DAY GETDATE GETUTCDATE ISDATE MONTH SYSDATETIME YEAR
  • 22.
    Date Type functions SELECTDATEPART (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]
  • 23.
  • 24.
     Arithmetic operators Assignment operators  Comparison operators  Logical operators  String operators
  • 25.
     Arithmetic operators Assignment operators  Comparison operators  Logical operators  Arithmetic operators
  • 26.
     Arithmetic operators Assignment operators  Comparison operators  Logical operators  Comparison operators
  • 27.
     Arithmetic operators Assignment operators  Comparison operators  Logical operators  Logical operators AND OR NOT LIKE BETWEE N IN
  • 28.
  • 29.
    ` What and whyof Constraints ? Constraints are the rules enforced on the data columns of a table  SQL NOT NULL  UNIQUE  PRIMARY KEY  FOREIGN KEY  CHECK  DEFAULT
  • 30.
    ` Primary key, UniqueKey, & Foreign key Empi d Ename Project # Deptno Salary Phone # 101 John WMDM 10 15020 932-001- 4739 102 Thoma s HCDW 20 23495 103 Rajesh SCAS 10 148292 Deptno Dname Location 10 Accounts 20 IT Employee Department Primary Key Foreign Key Primary Key Unique Key
  • 31.
  • 32.
    ` Types of Joins Constraintsare the rules enforced on the data columns of a table INNER JOIN LEFT JOIN RIGHT JOIN FULL JOIN SELF JOIN CARTESIAN JOIN
  • 33.
    How to dropsql server
  • 34.
    How to dropa sql database
  • 37.
  • 38.
     Rounding Functions Aggregation Functions  Logical Functions A ready to use data in SQL Server table 1 2 Prerequisites SQL Server and SSMS installed