Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary SQL Basics – Microsoft SQL Server Tutorial for Beginners – Complete Notes with Examples

Rating
-
Sold
-
Pages
75
Uploaded on
12-05-2025
Written in
2024/2025

This beginner-friendly guide to SQL provides a complete overview of database fundamentals, focusing on Microsoft SQL Server and T-SQL. Topics include DDL and DML, creating and managing tables, constraints, inserting and updating data, SELECT queries, JOIN operations, views, stored procedures, functions, triggers, and SQL scripts. The document combines clear explanations with practical examples and syntax, making it ideal for new learners or students preparing for SQL-based exams.

Show more Read less
Institution
Course

Content preview

Table of Contents
1 Introduction to SQL ........................................................................................................... 6

1.1 Data Definition Language (DDL).................................................................................. 8

1.2 Data Manipulation Language (DML) ........................................................................... 8

2 Introduction to SQL Server ................................................................................................ 9

2.1 SQL Server Management Studio ............................................................................... 10

2.1.1 Create a new Database...................................................................................... 11

2.1.2 Queries .............................................................................................................. 12

3 CREATE TABLE ................................................................................................................. 13

3.1 Database Modelling .................................................................................................. 15

3.2 Create Tables using the Designer Tools .................................................................... 17

3.3 SQL Constraints ......................................................................................................... 17

3.3.1 PRIMARY KEY ..................................................................................................... 18

3.3.2 FOREIGN KEY ..................................................................................................... 19

3.3.3 NOT NULL / Required Columns ......................................................................... 22

3.3.4 UNIQUE ............................................................................................................. 23

3.3.5 CHECK ................................................................................................................ 25

3.3.6 DEFAULT ............................................................................................................ 27

3.3.7 AUTO INCREMENT or IDENTITY ......................................................................... 28

3.4 ALTER TABLE ............................................................................................................. 29

4 INSERT INTO .................................................................................................................... 31

5 UPDATE ........................................................................................................................... 33

3

,4 Table of Contents

6 DELETE ............................................................................................................................. 35

7 SELECT ............................................................................................................................. 37

7.1 The ORDER BY Keyword ............................................................................................ 39

7.2 SELECT DISTINCT ....................................................................................................... 40

7.3 The WHERE Clause .................................................................................................... 40

7.3.1 Operators .......................................................................................................... 41

7.3.2 LIKE Operator .................................................................................................... 41

7.3.3 IN Operator........................................................................................................ 42

7.3.4 BETWEEN Operator ........................................................................................... 42

7.4 Wildcards .................................................................................................................. 42

7.5 AND & OR Operators ................................................................................................ 43

7.6 SELECT TOP Clause .................................................................................................... 44

7.7 Alias .......................................................................................................................... 45

7.8 Joins .......................................................................................................................... 45

7.8.1 Different SQL JOINs ........................................................................................... 46

8 SQL Scripts ....................................................................................................................... 48

8.1 Using Comments ....................................................................................................... 48

8.1.1 Single-line comment .......................................................................................... 48

8.1.2 Multiple-line comment ...................................................................................... 48

8.2 Variables ................................................................................................................... 49

8.3 Built-in Global Variables ........................................................................................... 50

8.3.1 @@IDENTITY ..................................................................................................... 50

8.4 Flow Control ............................................................................................................. 51

8.4.1 IF – ELSE ............................................................................................................. 51

8.4.2 WHILE ................................................................................................................ 52

8.4.3 CASE................................................................................................................... 53

Structured Query Language (SQL)

,5 Table of Contents

8.4.4 CURSOR ............................................................................................................. 54

9 Views ............................................................................................................................... 56

9.1 Using the Graphical Designer ................................................................................... 57

10 Stored Procedures ........................................................................................................ 61

10.1 NOCOUNT ON/NOCOUNT OFF .............................................................................. 64

11 Functions ...................................................................................................................... 66

11.1 Built-in Functions .................................................................................................. 66

11.1.1 String Functions ............................................................................................. 66

11.1.2 Date and Time Functions ............................................................................... 67

11.1.3 Mathematics and Statistics Functions ........................................................... 67

11.1.4 AVG() .............................................................................................................. 68

11.1.5 COUNT() ......................................................................................................... 68

11.1.6 The GROUP BY Statement.............................................................................. 69

11.1.7 The HAVING Clause ........................................................................................ 70

11.2 User-defined Functions ......................................................................................... 71

12 Triggers ......................................................................................................................... 72

13 Communication from other Applications ..................................................................... 75

13.1 ODBC ..................................................................................................................... 75

13.2 Microsoft Excel ...................................................................................................... 76

14 References .................................................................................................................... 78




Structured Query Language (SQL)

, 1 Introduction to SQL
SQL (Structured Query Language) is a database computer language designed for managing
data in relational database management systems (RDBMS).

SQL, is a standardized computer language that was originally developed by IBM for querying,
altering and defining relational databases, using declarative statements.

SQL is pronounced /ˌɛs kjuː ˈɛl/ (letter by letter) or /ˈsiːkwəl/ (as a word).




What can SQL do?

• SQL can execute queries against a database
• SQL can retrieve data from a database
• SQL can insert records in a database
• SQL can update records in a database
• SQL can delete records from a database

6

Written for

Institution
Course

Document information

Uploaded on
May 12, 2025
Number of pages
75
Written in
2024/2025
Type
SUMMARY

Subjects

$5.57
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
ariefnaufal

Get to know the seller

Seller avatar
ariefnaufal Universitas DIan Nuswantoro
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
3
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions