SlideShare a Scribd company logo
1 of 181
Introduction to Structured Query
Language (SQL)
By Techandmate.com
Learn SQL Server With US
Objectives
2
๏‚— Explore basic commands and functions of SQL
๏‚— How to use SQL for data administration (to create
tables, indexes, and views)
๏‚— How to use SQL for data manipulation (to add,
modify, delete, and retrieve data)
๏‚— How to use SQL to query a database to extract
useful information
Agenda
๏‚— What is SQL ?
๏‚— Data Types
๏‚— Constraints
๏‚— Database Relationships
๏‚— SQL Queries
๏‚— Transact- SQL Commands | DDL , DCL ,DML
๏‚— Retrieving Data
๏‚— Customizing Data
๏‚— Grouping Data
๏‚— SQL Operators
๏‚— Joining Data
Agenda continue
๏‚— Inserting , Updating and Deleting Data
๏‚— Working With Tables
๏‚— Working with Views
๏‚— Working With Constraints
๏‚— Generating Scripts
๏‚— Working with Stored Procedures
๏‚— Working with Functions
Introduction to SQL
5
๏‚— SQL stands for Structured Query Language. SQL is used to
communicate with a database. According to ANSI (American
National Standards Institute), it is the standard language for
relational database management systems
๏‚— SQL functions fit into two broad categories:
๏‚— Data definition language
๏‚— SQL includes commands to:
๏‚— Create database objects, such as tables, indexes, and
views
๏‚— Define access rights to those database objects
๏‚— Data manipulation language
๏‚— Includes commands to insert, update, delete, and retrieve
data within database tables
SQL Database Objects
๏‚— A SQL Server database has lot of objects like
๏‚— Tables
๏‚— Views
๏‚— Stored Procedures
๏‚— Functions
๏‚— Rules
๏‚— Defaults
๏‚— Cursors
๏‚— Triggers
SQL Server Data types
๏‚— Integer : Stores whole number
๏‚— Float : Stores real numbers
๏‚— Text : Stores characters
๏‚— Decimal: Stores real numbers
๏‚— Money : Stores monetary data. Supports 4 places
after decimal
๏‚— Date : Stores date and time
๏‚— Binary : Stores images and other large objects
๏‚— Miscellaneous : Different types special to SQL Server.
๏‚— A null value is an unknown
๏‚— Null value is not as zero or space.
๏‚— every value in a column or set of columns must
be unique.
๏‚— When there is not the primary key.
๏‚— Example
๏‚— no two employees can have the same phone
number
๏‚— The primary key value must be unique and not null.
๏‚— Multiple UNIQUE constraints and only one Primary
key in a Table .
๏‚— FOREIGN KEY in one table points to a PRIMARY
KEY in another table.
๏‚— prevents that invalid data form being inserted into the
foreign key column
๏‚— used to limit the value range that can be placed in a
column.
๏‚— Example :
๏‚— A column must only include integers greater than 0
๏‚— used to insert a default value into a column
๏‚— Create , Alter , Drop , Truncate
๏‚— meant to deal with the structure of the database objects (the
object itself) like tables, views, procedures and so on.
๏‚— Insert , Delete , Update , SELECT
๏‚— deal with the contents of the tables rather than the structure
of the tables
๏‚— GRANT , DENY , REVOKE
๏‚— maintain security of the database objects access and use
๏‚— adding a new database object to the database
๏‚— changing the structure of an existing database
object
๏‚— removing a database object from the database
permanently
๏‚— removing all rows from a table without logging the
individual row deletions
๏‚— retrieving data from the database by specifying
which columns and rows to be retrieved
๏‚— adding a new row (and not column) into the table
๏‚— modifying the existing data in the tabl
๏‚— removing an existing data from the table
๏‚— giving privileges to the users
๏‚— denies permissions from a security account in the
current database and prevents the security account
from inheriting the permission through its group or
role memberships
๏‚— removing privileges from the users that are
previously granted those permissions
๏‚— Retrieve data from database
SELECT * | column1 [, column2,
โ€ฆโ€ฆ.]
FROM table
๏‚— Specify a condition to limit the result
SELECT * | column1 [, column2, โ€ฆโ€ฆ.]
FROM table
[WHERE conditions]
๏‚— sort the retrieved rows by a specific column or set of
columns
SELECT * | column1 [, column2, โ€ฆโ€ฆ.]
FROM table
[WHERE conditions]
[ORDER BY column1 [, column2, โ€ฆโ€ฆ..] ASC,
DESC]
1
2
๏‚— eliminates duplicate row values from the results
๏‚— Example : the Next Slide
๏‚— used to divide the rows in a table into smaller
groups
SELECT * | column1, group_function (column2),
โ€ฆโ€ฆ.
FROM table
[WHERE conditions]
[GROUP BY column1, โ€ฆโ€ฆ..]
[ORDER BY column1 [, column2, โ€ฆโ€ฆ..] ASC,
DESC]
๏‚— used to restrict the group results
SELECT * | column1, group_function (column2),
โ€ฆโ€ฆ.
FROM table
[WHERE conditions]
[GROUP BY column1, โ€ฆโ€ฆ..]
HAVING [conditions]
[ORDER BY column1 [, column2, โ€ฆโ€ฆ..] ASC,
DESC]
๏‚— Arithmetic operators
๏‚— Comparison operators
๏‚— Logical operators
๏‚— Set Operators
๏‚— Other operators
๏‚— addition (+)
๏‚— subtraction (-)
๏‚— multiplication (*)
๏‚— division (/).
๏‚— compare two or more values
DescriptionOperator
Equal=
Lease than<
Greater than>
Less than or equal<=
Greater than or equal>=
Not Equal<>
โ€ข Used to get a logical value (True or
False)
๏‚— combine the results of two or more queries into one
result
๏‚— UNION/ UNION ALL
๏‚— INTERSECT
๏‚— EXCEPT
EmpLacation
Egypt
Canada
Egypt
VacLocation
Egypt
Canada
France
Union
Egypt
Canada
France
Intersect
Egypt
Canada
Except
France
โ€ข Create a Single Result Set from
Multiple Queries
โ€“ Similar data types
โ€“ Same number of columns
โ€“ Same column order in select list
USE northwind
SELECT (firstname + ' ' + lastname) AS name
,city, postalcode
FROM employees
UNION
SELECT companyname, city, postalcode
FROM customers
GO
๏‚— returns only the records that have the same values
in the selected columns in both tables.
USE northwind
SELECT (firstname + ' ' + lastname) AS name
,city, postalcode
FROM employees
INTERSECT
SELECT companyname, city, postalcode
FROM customers
GO
๏‚— return rows returned by the first query that are not
present in the second query
USE northwind
SELECT (firstname + ' ' + lastname) AS name
,city, postalcode
FROM employees
EXCEPT
SELECT companyname, city, postalcode
FROM customers
GO
๏‚— Example 1 (without an alias name)
๏‚— Example 2 (with an alias name)
USE joindb
SELECT buyer_name, s.buyer_id, qty
FROM buyers AS b INNER JOIN sales AS s
ON b.buyer_id = s.buyer_id
GO
USE joindb
SELECT buyer_name, sales.buyer_id, qty
FROM buyers INNER JOIN sales
ON buyers.buyer_id = sales.buyer_id
GO
This slide from 2071b from Microsoft
๏‚— Introduction to Joins
๏‚— Using Inner Joins
๏‚— Using Outer Joins
๏‚— Using Cross Joins
๏‚— Joining More Than Two Tables
๏‚— Joining a Table to Itself
๏‚— Selects Specific Columns from Multiple Tables
๏‚— JOIN keyword specifies that tables are joined and
how to join them
๏‚— ON keyword specifies join condition
๏‚— Queries Two or More Tables to Produce a Result
Set
๏‚— Use primary and foreign keys as join conditions
๏‚— Use columns common to specified tables to join
tables
๏‚— return rows only when there is at least one row from
both tables that matches the join condition
SELECT <select list>
FROM table1 inner join table2
ON (table1.column1 = table2.column2)
USE joindb
SELECT buyer_name, sales.buyer_id, qty
FROM buyers INNER JOIN sales
ON buyers.buyer_id = sales.buyer_id
GO
sales
buyer_id prod_id qty
1
1
4
3
2
3
1
5
15
5
37
11
4 2 1003
buyers
buyer_name
Adam Barr
Sean Chai
Eva Corets
Erin Oโ€™Melia
buyer_id
1
2
3
4
Result
buyer_name
Adam Barr
Adam Barr
Erin Oโ€™Melia
Eva Corets
buyer_id qty
1
1
4
3
15
5
37
11
Erin Oโ€™Melia 4 1003
Example 1
๏‚— includes all rows in the left table in the results whether or
not there are matching values on the common column in the
right table. in addition to the matching values in Both table.
: All rows from the Left table are returned
SELECT <select list>
FROM table1 left outer join table2
ON (table1.column1 = table2.column2)
USE joindb
SELECT buyer_name, sales.buyer_id, qty
FROM buyers LEFT OUTER JOIN sales
ON buyers.buyer_id = sales.buyer_id
GO
sales
buyer_id prod_id qty
1
1
4
3
2
3
1
5
15
5
37
11
4 2 1003
buyers
buyer_name
Adam Barr
Sean Chai
Eva Corets
Erin Oโ€™Melia
buyer_id
1
2
3
4
Result
buyer_name
Adam Barr
Adam Barr
Erin Oโ€™Melia
Eva Corets
buyer_id qty
1
1
4
3
15
5
37
11
Erin Oโ€™Melia 4 1003
Sean Chai NULL NULL
Example 1
๏‚— the reverse of LEFT OUTER joins
๏‚— All rows from the right table are returned
๏‚— Null values are returned for the left table any time a right
table row has no matching row in the left table.
SELECT <select list>
FROM table1 right outer join table2
ON (table1.column1 =
table2.column2)
๏‚— returns all the rows from the left table , and all the
rows from the right table
๏‚— Also it returns rows in the left table that do not
have matches in the right table, or if there are
rows in right table that do not have matches in the
left table.
NameID
Some11
Some22
Some33
CountryID
Loc11
Loc22
Loc44
SELECT a.id ,b.id, a.name , b.country
FROM LeftTable as a
Full Join RightTable as b
On a.id = b.id
Full Join
๏‚— Join table with it self
SELECT a.column , b.column
FROM Table1 as a
JOIN Table1 as b
ON a.column = b.column
โ€ข I want Every Employee Name with his Manager
๏‚— return all rows from both tables
๏‚— Each row from the left table is combined with all
rows from Second Table
๏‚— the number of rows in the left table multiplied by
the number of rows in the right table.
๏‚— Table1 >> 2 rows,
๏‚— Table2 >> 5 rows,
๏‚— >>10 rows
๏‚— Example :
๏‚— Possible ways
Name
Ali
Islam
Country
Egypt
Cairo
CountryName
EgyptAli
CairoAli
EgyptIslam
CairoIslam
USE joindb
SELECT buyer_name, qty
FROM buyers
CROSS JOIN sales
GO
Result
buyer_name
Adam Barr
Adam Barr
Adam Barr
Adam Barr
qty
15
5
37
11
Adam Barr 1003
Sean Chai 15
Sean Chai 5
Sean Chai 37
Sean Chai 11
Sean Chai 1003
Eva Corets 15
... ...
sales
buyer_id prod_id qty
1
1
4
3
2
3
1
5
15
5
37
11
4 2 1003
buyers
buyer_id
1
2
3
4
buyer_name
Adam Barr
Sean Chai
Eva Corets
Erin Oโ€™Melia
Example 1
๏‚— is responsible for adding a new row into the
table
INSERT [INTO] table
[column1, column2, โ€ฆโ€ฆโ€ฆ..]
VALUES (value1, value2, โ€ฆโ€ฆโ€ฆโ€ฆ.. )
โ€ข Inserting Data without columns
name
โ€ข Inserting Data with columns name
Note: You can verify the result by write SELECT
statement.
SELECT โ€ฆโ€ฆ <select_list>
INTO <new_table>
FROM <table_name>
[WHERE <search_condition>]
๏‚— is responsible for modifying the existing data in the
table
UPDATE <table>
SET column1 = value1 [, column2 = value2, โ€ฆโ€ฆ]
WHERE [conditions]
๏‚— is responsible for removing an existing data from
the table
DELETE <table>
WHERE [conditions]
:
๏‚— removes all rows from a table
TRUNCATE Table <table>
๏‚— is new statement in SQL Server 2008
๏‚— INSERT, UPDATE, and DELETE in a single
statement . Based on Condition
MERGE INTO table_name table_alias
USING (table|view|sub_query) alias
ON (join condition)
WHEN MATCHED THEN
UPDATE SET
col1 = col_val1,
col2 = col2_val
WHEN NOT MATCHED THEN
INSERT (column_list)
VALUES (column_values);
๏‚— Using User Interface
๏‚— create new tables
CREATE TABLE <table_name>
(
column1 datatype ,
column2 datatype ,
...............
(
๏‚— Altering an existing table
๏‚— Using User Interface
modify existing tables
ALTER TABLE <table_name>
Add colum_name datatype
ALTER TABLE <table_name>
ALTER COLUMN colum_name datatype
ALTER TABLE <table_name>
DROP COLUMN colum_name datatype
๏‚— Disallow null , and decrease length
๏‚— Dropping an existing table
๏‚— drop existing tables
: Donโ€™t forget to Press Refresh
DROP TABLE <table_name>
๏‚— is simply a SELECT statement that has been given
a name and stored in a database
๏‚— Restricting data access
๏‚— Making complex queries easy
CREATE VIEW <view_name>
AS <select_statement>
Create View LondonEmployees
as
SELECT EmloyeeId , LastName , FirstName
,City , Address
FROM Employees
๏‚— Any changes to View that may cause a record
disappear from the view , will raises runtime error
.
๏‚— Example :
Create view SomeOrders
as
SELECT * FROM Orders where Orders.ShipCity =
'Londonโ€˜
With Check Option
๏‚— Creating tables with constraints
๏‚— add a new constraint
๏‚— Create a new Database >> New Database
๏‚— Attach Existing Database >> Attach
๏‚— removes the database entry from the instance
๏‚— closes all files associated to the database
๏‚— releases all operating system locks
๏‚— Detaching a database
๏‚— Database diagrams graphically show the structure
of the database
1. Select your database from the Databases node
in the Object Explorer.
2. Right-click the Database Diagrams folder.
3. Select the New Database Diagram
:
:
๏‚— Files with Extension (.sql )
script1.sql
:
๏ƒ˜a sequence of operations performed as a single
logical unit of work.
๏ƒ˜all of its data modifications are performed or none of
them is performed.
๏‚— Autocommit transactions
๏ƒ˜ The default for SQL Server
๏ƒ˜ Each individual DML or DDL statement is committed when it
Completes
๏ƒ˜ You do not have to specify any statements to control
transactions
๏‚— Implicit transactions
๏ƒ˜SET IMPLICIT_TRANSACTIONS ON
๏ƒ˜Each Transact-SQL statement
(INSERT,UPDATE,DELETE) execute as a
Transaction
๏‚— Explicit transactions
๏ƒ˜Starting with BEGIN TRANSACTION Statement
: The COMMIT statement.
: The ROLLBACK statement .
>> automatically Rollback
๏‚— If it prevents the successful completion of a
transaction
>> need to Check @@Error
๏‚— constraint violation (Check Constraint )
๏ƒ˜Define a location to which a transaction can return
๏ƒ˜like save point in any game
SAVE TRANSACTION <savepoint_name>
ROLLBACK TRANSACTION
<savepoint_name>
๏‚— You Can :
๏‚— Contains Statement that Perform Operations
๏‚— Accept input Parameters
๏‚— Return Status Value
๏‚— success or failure
๏‚— Return Multiple Output parameters
๏‚— They are registered (permanently stored) at the
server.
๏‚— They can have security attributes (such as
permissions).
๏‚— They can enhance the security of your
application.
๏‚— They allow modular programming.
๏‚— They are named code and so they allow
repeating execution.
๏‚— They can reduce network traffic.
๏‚— User-defined stored procedures
๏‚— System stored procedures
CREATE PROC | PROCEDURE
<procedure_name>
[@parameter data_type]
AS <sql_statement>
ALTER PROC | PROCEDURE
<procedure_name>
[@parameter data_type]
AS <sql_statement>
DROP PROC | PROCEDURE <procedure_name>
๏‚— Like functions in programming languages
๏‚— accept parameters
๏‚— perform an action
๏‚— return the result of that action as a value
๏‚— They allow modular programming.
๏‚— They allow faster execution.
๏‚— They always return a value to the calling program.
๏‚— User-defined scalar functions
๏‚— Built-in Functions
CREATE FUNCTION <function_name>
[(@parameter data_type)]
RETURNS return_data_type | table
[AS]
BEGIN
function_code
RETURN scalar_expression | select
statement
END
๏‚— specifies TABLE as a return data type
๏‚— returns a SELECT statement rather than a single
value
๏‚— Using the ALTER FUNCTION statement
ALTER FUNCTION <function_name>
[(@parameter data_type)]
RETURNS return_data_type
[AS]
BEGIN
function_code
RETURN scalar_expression
END
DROP FUNCTION <function_name>
๏‚— a special type of stored procedure.
๏‚— Invoked automatically
๏‚— Not called directly
๏‚— DDL triggers
๏‚— DML triggers
๏‚— They can query other tables and include complex
Transact-SQL statements
๏‚— They can reference columns in other tables
๏‚— with more complex than check
๏‚— override the standard actions
CREATE TRIGGER <trigger_name> on <table
| view>
INSTEAD OF INSERT | UPDATE | DELETE
AS
BEGIN
<trigger_code>
END
๏‚— INSTEAD OF INSERT triggers
๏‚— INSTEAD OF UPDATE triggers
๏‚— INSTEAD OF DELETE triggers
Create a trigger that protects all the data in
the Course table from deletion
:
create trigger that insert new trainee when
inserting new course
๏‚— Alter and Drop statements
: Drop trigger
๏‚— This is not every thing about Transact-SQL
๏‚— This is just an introduction
๏‚— May you read :
๏‚— 2071B Book (Querying MS SQL Server with Transact-SQL )
๏‚— 2073A Book(Programming MS SQL Server Database)
๏‚— MSDN : http://msdn.microsoft.com/en-
us/library/aa299742(v=SQL.80).aspx
๏‚— Google
SQL Server Learning Drive

More Related Content

What's hot

Mysql
MysqlMysql
MysqlTSUBHASHRI
ย 
Sql select
Sql select Sql select
Sql select Mudasir Syed
ย 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sqlVARSHAKUMARI49
ย 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Punjab University
ย 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)Sabana Maharjan
ย 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)pptGowarthini
ย 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and HistorySomeshwarMoholkar
ย 
Sql - Structured Query Language
Sql - Structured Query LanguageSql - Structured Query Language
Sql - Structured Query LanguageWan Hussain Wan Ishak
ย 
Sql clauses by Manan Pasricha
Sql clauses by Manan PasrichaSql clauses by Manan Pasricha
Sql clauses by Manan PasrichaMananPasricha
ย 
plsql les10
 plsql les10 plsql les10
plsql les10sasa_eldoby
ย 
SQL Queries
SQL QueriesSQL Queries
SQL QueriesNilt1234
ย 

What's hot (20)

Mysql
MysqlMysql
Mysql
ย 
Sql select
Sql select Sql select
Sql select
ย 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
ย 
SQL
SQLSQL
SQL
ย 
Basic SQL
Basic SQLBasic SQL
Basic SQL
ย 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
ย 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
ย 
Sql and Sql commands
Sql and Sql commandsSql and Sql commands
Sql and Sql commands
ย 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
ย 
SQL
SQLSQL
SQL
ย 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
ย 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
ย 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
ย 
Sql commands
Sql commandsSql commands
Sql commands
ย 
Sql - Structured Query Language
Sql - Structured Query LanguageSql - Structured Query Language
Sql - Structured Query Language
ย 
Sql clauses by Manan Pasricha
Sql clauses by Manan PasrichaSql clauses by Manan Pasricha
Sql clauses by Manan Pasricha
ย 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
ย 
plsql les10
 plsql les10 plsql les10
plsql les10
ย 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
ย 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
ย 

Viewers also liked

Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basicsrainynovember12
ย 
MS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsMS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsDataminingTools Inc
ย 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Beat Signer
ย 
What Is SQL?
What Is SQL?What Is SQL?
What Is SQL?QATestLab
ย 
Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101IDERA Software
ย 
SQL 101 for business experts and stakeholders
SQL 101 for business experts and stakeholdersSQL 101 for business experts and stakeholders
SQL 101 for business experts and stakeholdersIvรกn Stepaniuk
ย 
SQL DDL
SQL DDLSQL DDL
SQL DDLVikas Gupta
ย 
Complex queries in sql
Complex queries in sqlComplex queries in sql
Complex queries in sqlCharan Reddy
ย 
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT StatementsWriting Basic SQL SELECT Statements
Writing Basic SQL SELECT StatementsSalman Memon
ย 
Sql server 2012 ha dr
Sql server 2012 ha drSql server 2012 ha dr
Sql server 2012 ha drJoseph D'Antoni
ย 
ASP.NET Core deployment options
ASP.NET Core deployment optionsASP.NET Core deployment options
ASP.NET Core deployment optionsKen Cenerelli
ย 
OOPs fundamentals session for freshers in my office (Aug 5, 13)
OOPs fundamentals session for freshers in my office (Aug 5, 13)OOPs fundamentals session for freshers in my office (Aug 5, 13)
OOPs fundamentals session for freshers in my office (Aug 5, 13)Ashoka R K T
ย 
Javascript and Jquery: The connection between
Javascript and Jquery: The connection betweenJavascript and Jquery: The connection between
Javascript and Jquery: The connection betweenClint LaForest
ย 
009 sql server management studio
009 sql server management studio009 sql server management studio
009 sql server management studiolet's go to study
ย 
.Net framework architecture
.Net framework architecture.Net framework architecture
.Net framework architectureFad Zulkifli
ย 
Back to the Basics - 1 - Introduction to Web Development
Back to the Basics - 1 - Introduction to Web DevelopmentBack to the Basics - 1 - Introduction to Web Development
Back to the Basics - 1 - Introduction to Web DevelopmentClint LaForest
ย 
ASP.NET OVERVIEW
ASP.NET OVERVIEWASP.NET OVERVIEW
ASP.NET OVERVIEWRishi Kothari
ย 
Future Web Trends - at Innovation series with Jimmy Wales
Future Web Trends - at Innovation series with Jimmy WalesFuture Web Trends - at Innovation series with Jimmy Wales
Future Web Trends - at Innovation series with Jimmy WalesMatthew Buckland
ย 

Viewers also liked (20)

Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basics
ย 
MS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsMS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database Concepts
ย 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
ย 
What Is SQL?
What Is SQL?What Is SQL?
What Is SQL?
ย 
Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101
ย 
SQL 101 for business experts and stakeholders
SQL 101 for business experts and stakeholdersSQL 101 for business experts and stakeholders
SQL 101 for business experts and stakeholders
ย 
Les01 Writing Basic Sql Statements
Les01 Writing Basic Sql StatementsLes01 Writing Basic Sql Statements
Les01 Writing Basic Sql Statements
ย 
SQL DDL
SQL DDLSQL DDL
SQL DDL
ย 
Complex queries in sql
Complex queries in sqlComplex queries in sql
Complex queries in sql
ย 
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT StatementsWriting Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
ย 
Sql server 2012 ha dr
Sql server 2012 ha drSql server 2012 ha dr
Sql server 2012 ha dr
ย 
ASP.NET Core deployment options
ASP.NET Core deployment optionsASP.NET Core deployment options
ASP.NET Core deployment options
ย 
OOPs fundamentals session for freshers in my office (Aug 5, 13)
OOPs fundamentals session for freshers in my office (Aug 5, 13)OOPs fundamentals session for freshers in my office (Aug 5, 13)
OOPs fundamentals session for freshers in my office (Aug 5, 13)
ย 
Javascript and Jquery: The connection between
Javascript and Jquery: The connection betweenJavascript and Jquery: The connection between
Javascript and Jquery: The connection between
ย 
009 sql server management studio
009 sql server management studio009 sql server management studio
009 sql server management studio
ย 
.Net framework architecture
.Net framework architecture.Net framework architecture
.Net framework architecture
ย 
Back to the Basics - 1 - Introduction to Web Development
Back to the Basics - 1 - Introduction to Web DevelopmentBack to the Basics - 1 - Introduction to Web Development
Back to the Basics - 1 - Introduction to Web Development
ย 
ASP.NET OVERVIEW
ASP.NET OVERVIEWASP.NET OVERVIEW
ASP.NET OVERVIEW
ย 
C# fundamentals Part 2
C# fundamentals Part 2C# fundamentals Part 2
C# fundamentals Part 2
ย 
Future Web Trends - at Innovation series with Jimmy Wales
Future Web Trends - at Innovation series with Jimmy WalesFuture Web Trends - at Innovation series with Jimmy Wales
Future Web Trends - at Innovation series with Jimmy Wales
ย 

Similar to SQL Server Learning Drive

DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxjainendraKUMAR55
ย 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic ConceptsTony Wong
ย 
SQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptxSQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptxssuser6bf2d1
ย 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptxEllenGracePorras
ย 
SQL Query
SQL QuerySQL Query
SQL QueryImam340267
ย 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDev Chauhan
ย 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...SakkaravarthiS1
ย 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQueryAbhishek590097
ย 
Day-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxDay-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxuzmasulthana3
ย 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1sagaroceanic11
ย 
Sql slid
Sql slidSql slid
Sql slidpacatarpit
ย 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server iiIblesoft
ย 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2SQL Tutorial for BCA-2
SQL Tutorial for BCA-2Raj vardhan
ย 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxEliasPetros
ย 
SQL Fundamentals
SQL FundamentalsSQL Fundamentals
SQL FundamentalsBrian Foote
ย 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfDraguClaudiu
ย 

Similar to SQL Server Learning Drive (20)

DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
ย 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
ย 
SQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptxSQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptx
ย 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
ย 
SQL Query
SQL QuerySQL Query
SQL Query
ย 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
ย 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
ย 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
ย 
Day-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxDay-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptx
ย 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1
ย 
Sql slid
Sql slidSql slid
Sql slid
ย 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server ii
ย 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2SQL Tutorial for BCA-2
SQL Tutorial for BCA-2
ย 
Lab
LabLab
Lab
ย 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
ย 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
ย 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
ย 
SQL Fundamentals
SQL FundamentalsSQL Fundamentals
SQL Fundamentals
ย 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
ย 
Database Overview
Database OverviewDatabase Overview
Database Overview
ย 

Recently uploaded

VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
ย 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
ย 
Call Girls Bannerghatta Road Just Call ๐Ÿ‘— 7737669865 ๐Ÿ‘— Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call ๐Ÿ‘— 7737669865 ๐Ÿ‘— Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call ๐Ÿ‘— 7737669865 ๐Ÿ‘— Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call ๐Ÿ‘— 7737669865 ๐Ÿ‘— Top Class Call Girl Ser...amitlee9823
ย 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
ย 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
ย 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
ย 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
ย 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Delhi Call girls
ย 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
ย 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
ย 
Chintamani Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore ...Chintamani Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore ...amitlee9823
ย 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
ย 
Junnasandra Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore...Junnasandra Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore...amitlee9823
ย 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
ย 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
ย 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
ย 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxolyaivanovalion
ย 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171โœ”๏ธBody to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171โœ”๏ธBody to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171โœ”๏ธBody to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171โœ”๏ธBody to body massage wit...shivangimorya083
ย 

Recently uploaded (20)

VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
ย 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
ย 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
ย 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
ย 
Call Girls Bannerghatta Road Just Call ๐Ÿ‘— 7737669865 ๐Ÿ‘— Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call ๐Ÿ‘— 7737669865 ๐Ÿ‘— Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call ๐Ÿ‘— 7737669865 ๐Ÿ‘— Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call ๐Ÿ‘— 7737669865 ๐Ÿ‘— Top Class Call Girl Ser...
ย 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
ย 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
ย 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
ย 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
ย 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
ย 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
ย 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
ย 
Chintamani Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore ...Chintamani Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore ...
ย 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
ย 
Junnasandra Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore...Junnasandra Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: ๐Ÿ“ 7737669865 ๐Ÿ“ High Profile Model Escorts | Bangalore...
ย 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
ย 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
ย 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
ย 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptx
ย 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171โœ”๏ธBody to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171โœ”๏ธBody to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171โœ”๏ธBody to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171โœ”๏ธBody to body massage wit...
ย 

SQL Server Learning Drive

  • 1. Introduction to Structured Query Language (SQL) By Techandmate.com Learn SQL Server With US
  • 2. Objectives 2 ๏‚— Explore basic commands and functions of SQL ๏‚— How to use SQL for data administration (to create tables, indexes, and views) ๏‚— How to use SQL for data manipulation (to add, modify, delete, and retrieve data) ๏‚— How to use SQL to query a database to extract useful information
  • 3. Agenda ๏‚— What is SQL ? ๏‚— Data Types ๏‚— Constraints ๏‚— Database Relationships ๏‚— SQL Queries ๏‚— Transact- SQL Commands | DDL , DCL ,DML ๏‚— Retrieving Data ๏‚— Customizing Data ๏‚— Grouping Data ๏‚— SQL Operators ๏‚— Joining Data
  • 4. Agenda continue ๏‚— Inserting , Updating and Deleting Data ๏‚— Working With Tables ๏‚— Working with Views ๏‚— Working With Constraints ๏‚— Generating Scripts ๏‚— Working with Stored Procedures ๏‚— Working with Functions
  • 5. Introduction to SQL 5 ๏‚— SQL stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems ๏‚— SQL functions fit into two broad categories: ๏‚— Data definition language ๏‚— SQL includes commands to: ๏‚— Create database objects, such as tables, indexes, and views ๏‚— Define access rights to those database objects ๏‚— Data manipulation language ๏‚— Includes commands to insert, update, delete, and retrieve data within database tables
  • 6. SQL Database Objects ๏‚— A SQL Server database has lot of objects like ๏‚— Tables ๏‚— Views ๏‚— Stored Procedures ๏‚— Functions ๏‚— Rules ๏‚— Defaults ๏‚— Cursors ๏‚— Triggers
  • 7. SQL Server Data types ๏‚— Integer : Stores whole number ๏‚— Float : Stores real numbers ๏‚— Text : Stores characters ๏‚— Decimal: Stores real numbers ๏‚— Money : Stores monetary data. Supports 4 places after decimal ๏‚— Date : Stores date and time ๏‚— Binary : Stores images and other large objects ๏‚— Miscellaneous : Different types special to SQL Server.
  • 8. ๏‚— A null value is an unknown ๏‚— Null value is not as zero or space.
  • 9. ๏‚— every value in a column or set of columns must be unique. ๏‚— When there is not the primary key. ๏‚— Example ๏‚— no two employees can have the same phone number
  • 10. ๏‚— The primary key value must be unique and not null. ๏‚— Multiple UNIQUE constraints and only one Primary key in a Table .
  • 11. ๏‚— FOREIGN KEY in one table points to a PRIMARY KEY in another table. ๏‚— prevents that invalid data form being inserted into the foreign key column
  • 12. ๏‚— used to limit the value range that can be placed in a column. ๏‚— Example : ๏‚— A column must only include integers greater than 0
  • 13. ๏‚— used to insert a default value into a column
  • 14. ๏‚— Create , Alter , Drop , Truncate ๏‚— meant to deal with the structure of the database objects (the object itself) like tables, views, procedures and so on. ๏‚— Insert , Delete , Update , SELECT ๏‚— deal with the contents of the tables rather than the structure of the tables ๏‚— GRANT , DENY , REVOKE ๏‚— maintain security of the database objects access and use
  • 15. ๏‚— adding a new database object to the database ๏‚— changing the structure of an existing database object ๏‚— removing a database object from the database permanently ๏‚— removing all rows from a table without logging the individual row deletions
  • 16. ๏‚— retrieving data from the database by specifying which columns and rows to be retrieved ๏‚— adding a new row (and not column) into the table ๏‚— modifying the existing data in the tabl ๏‚— removing an existing data from the table
  • 17. ๏‚— giving privileges to the users ๏‚— denies permissions from a security account in the current database and prevents the security account from inheriting the permission through its group or role memberships ๏‚— removing privileges from the users that are previously granted those permissions
  • 18. ๏‚— Retrieve data from database SELECT * | column1 [, column2, โ€ฆโ€ฆ.] FROM table
  • 19.
  • 20. ๏‚— Specify a condition to limit the result SELECT * | column1 [, column2, โ€ฆโ€ฆ.] FROM table [WHERE conditions]
  • 21.
  • 22.
  • 23. ๏‚— sort the retrieved rows by a specific column or set of columns SELECT * | column1 [, column2, โ€ฆโ€ฆ.] FROM table [WHERE conditions] [ORDER BY column1 [, column2, โ€ฆโ€ฆ..] ASC, DESC]
  • 24.
  • 25. 1 2
  • 26.
  • 27.
  • 28. ๏‚— eliminates duplicate row values from the results ๏‚— Example : the Next Slide
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34. ๏‚— used to divide the rows in a table into smaller groups SELECT * | column1, group_function (column2), โ€ฆโ€ฆ. FROM table [WHERE conditions] [GROUP BY column1, โ€ฆโ€ฆ..] [ORDER BY column1 [, column2, โ€ฆโ€ฆ..] ASC, DESC]
  • 35.
  • 36. ๏‚— used to restrict the group results SELECT * | column1, group_function (column2), โ€ฆโ€ฆ. FROM table [WHERE conditions] [GROUP BY column1, โ€ฆโ€ฆ..] HAVING [conditions] [ORDER BY column1 [, column2, โ€ฆโ€ฆ..] ASC, DESC]
  • 37.
  • 38.
  • 39. ๏‚— Arithmetic operators ๏‚— Comparison operators ๏‚— Logical operators ๏‚— Set Operators ๏‚— Other operators
  • 40. ๏‚— addition (+) ๏‚— subtraction (-) ๏‚— multiplication (*) ๏‚— division (/).
  • 41. ๏‚— compare two or more values DescriptionOperator Equal= Lease than< Greater than> Less than or equal<= Greater than or equal>= Not Equal<>
  • 42.
  • 43. โ€ข Used to get a logical value (True or False)
  • 44.
  • 45. ๏‚— combine the results of two or more queries into one result ๏‚— UNION/ UNION ALL ๏‚— INTERSECT ๏‚— EXCEPT
  • 47. โ€ข Create a Single Result Set from Multiple Queries โ€“ Similar data types โ€“ Same number of columns โ€“ Same column order in select list USE northwind SELECT (firstname + ' ' + lastname) AS name ,city, postalcode FROM employees UNION SELECT companyname, city, postalcode FROM customers GO
  • 48. ๏‚— returns only the records that have the same values in the selected columns in both tables. USE northwind SELECT (firstname + ' ' + lastname) AS name ,city, postalcode FROM employees INTERSECT SELECT companyname, city, postalcode FROM customers GO
  • 49. ๏‚— return rows returned by the first query that are not present in the second query USE northwind SELECT (firstname + ' ' + lastname) AS name ,city, postalcode FROM employees EXCEPT SELECT companyname, city, postalcode FROM customers GO
  • 50.
  • 51.
  • 52. ๏‚— Example 1 (without an alias name) ๏‚— Example 2 (with an alias name) USE joindb SELECT buyer_name, s.buyer_id, qty FROM buyers AS b INNER JOIN sales AS s ON b.buyer_id = s.buyer_id GO USE joindb SELECT buyer_name, sales.buyer_id, qty FROM buyers INNER JOIN sales ON buyers.buyer_id = sales.buyer_id GO This slide from 2071b from Microsoft
  • 53. ๏‚— Introduction to Joins ๏‚— Using Inner Joins ๏‚— Using Outer Joins ๏‚— Using Cross Joins ๏‚— Joining More Than Two Tables ๏‚— Joining a Table to Itself
  • 54. ๏‚— Selects Specific Columns from Multiple Tables ๏‚— JOIN keyword specifies that tables are joined and how to join them ๏‚— ON keyword specifies join condition ๏‚— Queries Two or More Tables to Produce a Result Set ๏‚— Use primary and foreign keys as join conditions ๏‚— Use columns common to specified tables to join tables
  • 55. ๏‚— return rows only when there is at least one row from both tables that matches the join condition SELECT <select list> FROM table1 inner join table2 ON (table1.column1 = table2.column2)
  • 56. USE joindb SELECT buyer_name, sales.buyer_id, qty FROM buyers INNER JOIN sales ON buyers.buyer_id = sales.buyer_id GO sales buyer_id prod_id qty 1 1 4 3 2 3 1 5 15 5 37 11 4 2 1003 buyers buyer_name Adam Barr Sean Chai Eva Corets Erin Oโ€™Melia buyer_id 1 2 3 4 Result buyer_name Adam Barr Adam Barr Erin Oโ€™Melia Eva Corets buyer_id qty 1 1 4 3 15 5 37 11 Erin Oโ€™Melia 4 1003 Example 1
  • 57. ๏‚— includes all rows in the left table in the results whether or not there are matching values on the common column in the right table. in addition to the matching values in Both table. : All rows from the Left table are returned SELECT <select list> FROM table1 left outer join table2 ON (table1.column1 = table2.column2)
  • 58. USE joindb SELECT buyer_name, sales.buyer_id, qty FROM buyers LEFT OUTER JOIN sales ON buyers.buyer_id = sales.buyer_id GO sales buyer_id prod_id qty 1 1 4 3 2 3 1 5 15 5 37 11 4 2 1003 buyers buyer_name Adam Barr Sean Chai Eva Corets Erin Oโ€™Melia buyer_id 1 2 3 4 Result buyer_name Adam Barr Adam Barr Erin Oโ€™Melia Eva Corets buyer_id qty 1 1 4 3 15 5 37 11 Erin Oโ€™Melia 4 1003 Sean Chai NULL NULL Example 1
  • 59. ๏‚— the reverse of LEFT OUTER joins ๏‚— All rows from the right table are returned ๏‚— Null values are returned for the left table any time a right table row has no matching row in the left table. SELECT <select list> FROM table1 right outer join table2 ON (table1.column1 = table2.column2)
  • 60. ๏‚— returns all the rows from the left table , and all the rows from the right table ๏‚— Also it returns rows in the left table that do not have matches in the right table, or if there are rows in right table that do not have matches in the left table.
  • 61. NameID Some11 Some22 Some33 CountryID Loc11 Loc22 Loc44 SELECT a.id ,b.id, a.name , b.country FROM LeftTable as a Full Join RightTable as b On a.id = b.id Full Join
  • 62. ๏‚— Join table with it self SELECT a.column , b.column FROM Table1 as a JOIN Table1 as b ON a.column = b.column
  • 63. โ€ข I want Every Employee Name with his Manager
  • 64.
  • 65. ๏‚— return all rows from both tables ๏‚— Each row from the left table is combined with all rows from Second Table ๏‚— the number of rows in the left table multiplied by the number of rows in the right table. ๏‚— Table1 >> 2 rows, ๏‚— Table2 >> 5 rows, ๏‚— >>10 rows ๏‚— Example : ๏‚— Possible ways
  • 67. USE joindb SELECT buyer_name, qty FROM buyers CROSS JOIN sales GO Result buyer_name Adam Barr Adam Barr Adam Barr Adam Barr qty 15 5 37 11 Adam Barr 1003 Sean Chai 15 Sean Chai 5 Sean Chai 37 Sean Chai 11 Sean Chai 1003 Eva Corets 15 ... ... sales buyer_id prod_id qty 1 1 4 3 2 3 1 5 15 5 37 11 4 2 1003 buyers buyer_id 1 2 3 4 buyer_name Adam Barr Sean Chai Eva Corets Erin Oโ€™Melia Example 1
  • 68.
  • 69.
  • 70. ๏‚— is responsible for adding a new row into the table INSERT [INTO] table [column1, column2, โ€ฆโ€ฆโ€ฆ..] VALUES (value1, value2, โ€ฆโ€ฆโ€ฆโ€ฆ.. )
  • 71. โ€ข Inserting Data without columns name
  • 72. โ€ข Inserting Data with columns name Note: You can verify the result by write SELECT statement.
  • 73. SELECT โ€ฆโ€ฆ <select_list> INTO <new_table> FROM <table_name> [WHERE <search_condition>]
  • 74.
  • 75.
  • 76.
  • 77. ๏‚— is responsible for modifying the existing data in the table UPDATE <table> SET column1 = value1 [, column2 = value2, โ€ฆโ€ฆ] WHERE [conditions]
  • 78.
  • 79. ๏‚— is responsible for removing an existing data from the table DELETE <table> WHERE [conditions]
  • 80.
  • 81. : ๏‚— removes all rows from a table TRUNCATE Table <table>
  • 82. ๏‚— is new statement in SQL Server 2008 ๏‚— INSERT, UPDATE, and DELETE in a single statement . Based on Condition
  • 83. MERGE INTO table_name table_alias USING (table|view|sub_query) alias ON (join condition) WHEN MATCHED THEN UPDATE SET col1 = col_val1, col2 = col2_val WHEN NOT MATCHED THEN INSERT (column_list) VALUES (column_values);
  • 84.
  • 85.
  • 86.
  • 87.
  • 88. ๏‚— Using User Interface
  • 89. ๏‚— create new tables CREATE TABLE <table_name> ( column1 datatype , column2 datatype , ............... (
  • 90.
  • 91. ๏‚— Altering an existing table ๏‚— Using User Interface
  • 92. modify existing tables ALTER TABLE <table_name> Add colum_name datatype ALTER TABLE <table_name> ALTER COLUMN colum_name datatype ALTER TABLE <table_name> DROP COLUMN colum_name datatype
  • 93.
  • 94. ๏‚— Disallow null , and decrease length
  • 95.
  • 96. ๏‚— Dropping an existing table
  • 97.
  • 98. ๏‚— drop existing tables : Donโ€™t forget to Press Refresh DROP TABLE <table_name>
  • 99.
  • 100. ๏‚— is simply a SELECT statement that has been given a name and stored in a database ๏‚— Restricting data access ๏‚— Making complex queries easy
  • 101. CREATE VIEW <view_name> AS <select_statement> Create View LondonEmployees as SELECT EmloyeeId , LastName , FirstName ,City , Address FROM Employees
  • 102.
  • 103.
  • 104. ๏‚— Any changes to View that may cause a record disappear from the view , will raises runtime error . ๏‚— Example : Create view SomeOrders as SELECT * FROM Orders where Orders.ShipCity = 'Londonโ€˜ With Check Option
  • 105.
  • 106.
  • 107. ๏‚— Creating tables with constraints
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114. ๏‚— add a new constraint
  • 115.
  • 116.
  • 117. ๏‚— Create a new Database >> New Database ๏‚— Attach Existing Database >> Attach
  • 118. ๏‚— removes the database entry from the instance ๏‚— closes all files associated to the database ๏‚— releases all operating system locks ๏‚— Detaching a database
  • 119.
  • 120. ๏‚— Database diagrams graphically show the structure of the database 1. Select your database from the Databases node in the Object Explorer. 2. Right-click the Database Diagrams folder. 3. Select the New Database Diagram
  • 121. :
  • 122. :
  • 123.
  • 124.
  • 125.
  • 126.
  • 127. ๏‚— Files with Extension (.sql ) script1.sql
  • 128.
  • 129.
  • 130.
  • 131.
  • 132. : ๏ƒ˜a sequence of operations performed as a single logical unit of work. ๏ƒ˜all of its data modifications are performed or none of them is performed.
  • 133. ๏‚— Autocommit transactions ๏ƒ˜ The default for SQL Server ๏ƒ˜ Each individual DML or DDL statement is committed when it Completes ๏ƒ˜ You do not have to specify any statements to control transactions ๏‚— Implicit transactions ๏ƒ˜SET IMPLICIT_TRANSACTIONS ON ๏ƒ˜Each Transact-SQL statement (INSERT,UPDATE,DELETE) execute as a Transaction ๏‚— Explicit transactions ๏ƒ˜Starting with BEGIN TRANSACTION Statement
  • 134. : The COMMIT statement. : The ROLLBACK statement .
  • 135. >> automatically Rollback ๏‚— If it prevents the successful completion of a transaction >> need to Check @@Error ๏‚— constraint violation (Check Constraint )
  • 136.
  • 137.
  • 138.
  • 139. ๏ƒ˜Define a location to which a transaction can return ๏ƒ˜like save point in any game SAVE TRANSACTION <savepoint_name> ROLLBACK TRANSACTION <savepoint_name>
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145. ๏‚— You Can : ๏‚— Contains Statement that Perform Operations ๏‚— Accept input Parameters ๏‚— Return Status Value ๏‚— success or failure ๏‚— Return Multiple Output parameters
  • 146. ๏‚— They are registered (permanently stored) at the server. ๏‚— They can have security attributes (such as permissions). ๏‚— They can enhance the security of your application. ๏‚— They allow modular programming. ๏‚— They are named code and so they allow repeating execution. ๏‚— They can reduce network traffic.
  • 147. ๏‚— User-defined stored procedures ๏‚— System stored procedures
  • 148. CREATE PROC | PROCEDURE <procedure_name> [@parameter data_type] AS <sql_statement>
  • 149.
  • 150.
  • 151. ALTER PROC | PROCEDURE <procedure_name> [@parameter data_type] AS <sql_statement>
  • 152. DROP PROC | PROCEDURE <procedure_name>
  • 153.
  • 154. ๏‚— Like functions in programming languages ๏‚— accept parameters ๏‚— perform an action ๏‚— return the result of that action as a value ๏‚— They allow modular programming. ๏‚— They allow faster execution. ๏‚— They always return a value to the calling program.
  • 155. ๏‚— User-defined scalar functions ๏‚— Built-in Functions
  • 156.
  • 157. CREATE FUNCTION <function_name> [(@parameter data_type)] RETURNS return_data_type | table [AS] BEGIN function_code RETURN scalar_expression | select statement END
  • 158.
  • 159.
  • 160.
  • 161.
  • 162. ๏‚— specifies TABLE as a return data type ๏‚— returns a SELECT statement rather than a single value
  • 163.
  • 164.
  • 165.
  • 166.
  • 167. ๏‚— Using the ALTER FUNCTION statement ALTER FUNCTION <function_name> [(@parameter data_type)] RETURNS return_data_type [AS] BEGIN function_code RETURN scalar_expression END
  • 169.
  • 170. ๏‚— a special type of stored procedure. ๏‚— Invoked automatically ๏‚— Not called directly ๏‚— DDL triggers ๏‚— DML triggers
  • 171. ๏‚— They can query other tables and include complex Transact-SQL statements ๏‚— They can reference columns in other tables ๏‚— with more complex than check
  • 172. ๏‚— override the standard actions CREATE TRIGGER <trigger_name> on <table | view> INSTEAD OF INSERT | UPDATE | DELETE AS BEGIN <trigger_code> END
  • 173. ๏‚— INSTEAD OF INSERT triggers ๏‚— INSTEAD OF UPDATE triggers ๏‚— INSTEAD OF DELETE triggers
  • 174. Create a trigger that protects all the data in the Course table from deletion
  • 175.
  • 176. : create trigger that insert new trainee when inserting new course
  • 177.
  • 178.
  • 179. ๏‚— Alter and Drop statements : Drop trigger
  • 180. ๏‚— This is not every thing about Transact-SQL ๏‚— This is just an introduction ๏‚— May you read : ๏‚— 2071B Book (Querying MS SQL Server with Transact-SQL ) ๏‚— 2073A Book(Programming MS SQL Server Database) ๏‚— MSDN : http://msdn.microsoft.com/en- us/library/aa299742(v=SQL.80).aspx ๏‚— Google