Operators, ERD and T-SQL Statements in SQL Server

Operators, ERD and T-SQL Statements in SQL Server

SQL Server

In this post I will explain about Operators, ERD, and Basic T-SQL Statements in SQL Server. So let’s start.

Operators, ERD and T-SQL Statements in SQL Server

What are Operators in Microsoft SQL Server?

All the operators are a keyword that is used to filter the querying data and we can use it with WHERE clause. All operators list are mentioned below –

Operators, ERD and T-SQL Statements in SQL Server Part - 7: Welcome to the Microsoft SQL Server for beginners to professional tutorial here at https://raghawendrashukla.com/category/ms-sql/ portal; you can read articles online here related to Microsoft SQL Server from beginners to professional. I will try my best to help you. As we know that Microsoft SQL Server is a leading RDBMS (Relational Database Management System) and most of organizations are using it. If you are looking for an easy and efficient way to learn and become master of SQL Server then absolutely you are in the right place. Microsoft SQL Server for beginner’s tutorial is divided into many parts having huge practical and activities here. Once completed entire tutorial then you will be able to do installation of Microsoft SQL server into our PC and Laptops, configuration, querying data efficiently from tables or views in SQL server database, Create, Alter, Delete and Drop database objects like Database, Tables, Views, Indexes, Triggers, UDFs (User Defined Functions), Synonyms, SPs (Stored Procedures) and Sequences etc. In Part -6 we learnt Data Types and Wild Card Characters in Microsoft SQL Server, now we will learn about Operators, ERD and Basic T-SQL Statements in SQL Server. So let’s start. Operators, ERD and T-SQL Statements in SQL Server Part – 7 What are Operators in Microsoft SQL Server? All the operators are a keyword which are used to filter the querying data and we can use with WHERE clause. All operators list are mentioned below -

=, >, <, >=, <=, <>, !=, !>,!< Operators

Syntax:

IS NULL Operator

Syntax:

IS NOT NULL Operator

Syntax:

AND Operator

Syntax:

OR Operator

Syntax:

NOT Operator

Syntax:

BETWEEN Operator

Syntax:

LIKE Operator

Syntax:

IN Operator

Syntax:

ANY/ALL OPERATORS

The Operators (ANY/ ALL) are always used in combination with one of the comparison operators.

ANY Operator

An ANY operator evaluates to true if the result of an inner query contains at least one row that satisfies the comparison.

Syntax:

ALL Operator

The ALL operator evaluates to true if the evaluation of the table column in the inner query returns all values of that column.

Syntax:

SOME Operator

Syntax:

EXISTS Operator

Syntax:

What is ENTITY-RELATIONSHIP DIAGRAM (ERD)?

An entity-relationship (ER) diagram is a graphical representation of the inter-relationship between entities in a database. An ER diagram has the following elements:

  1. Entities
  2. Attributes
  3. Relationships

1. Entities: An entity is a distinct object, that information is stored in the database tables.

Example: Employees, Project

2. Attributes: An attribute is a property or descriptor of an entity.

Example: Employee ID, Name, Address, and Phone No are attributes of
entity – Employee.

3. Relationship: A relationship defines a connection between two entities.

Example: An employee works on a project. In this, works is the
relationship between the Employee and Project entities.

How many types of relationships in the entity-relationship diagram?

There are three types of relationships in entity relationship diagram:

  1. One-to-One Relationship
  • One-to-Many Relationship
  • Many-to-Many Relationship

1. One-to-One Relationships

A single instance of an entity can relate to only one instance of the other entity, called One-to-One relationship.

Example: a Person can have only one passport

2. One-to-Many Relationships

An instance of one entity can relate to multiple instances of another entity called One-to-Many relationship.

Example: a class has many students.

3. Many-to-Many Relationships

Multiple instances of an entity can relate to multiple instances of another entity, called a many-to-many relationship.

 Example: many copies of a book can be purchased by more than one customer.

How to generate Entity Relationship (ER) Diagram of a database in Microsoft SQL Server Management Studio?

If you want to generate ER diagram of SQL Server database using Microsoft SQL Server Management Studio then please follow below-mentioned steps –

  1. Go to SQL Server Management Studio >>
  2. Then Click on Object Explorer >>
  3. Then Databases >>
  4. Choose and expand your database >>
  5. Under your database right click on “Database Diagram” and click on “New
    Database Diagram”
ER

6. It will open a new window.

7. Choose tables to include in the ER diagram to select multiple tables you have to press the “ctrl”  or “shift” button and select tables.

8. Click Add

9. Wait for it to complete.

Operators, ERD and T-SQL Statements in SQL Server Part - 7
Operators, ERD and T-SQL Statements in SQL Server Part – 7

What the mean of basic T-SQL statements?

There are six statements bread and butter of T-SQL given bellow –

  • SELECT – extracts data from a database table.
  • INSERT – inserts new data into a database table
  • UPDATE – updates data in a database table.
  • DELETE – deletes data from a database table.
  • DROP – deletes table from a database.
  • TRUNCATE – deletes data from a database table and also resets the identity counter.
  1. The SELECT Statement and FROM Clause:

Result:

More Queries set to understand better for practice purpose:

2. The INSERT Statement and INTO Clause:

Syntax:

3. The UPDATE  Statement with SET and WHERE Clause:

Syntax:

4. The DELETE Statement with FROM and WHERE Clause:

Syntax:

5. The DROP Statement

Syntax:

6. The TRUNCATE Statement

Syntax:

I will discuss upcoming topics in next part. So please take care of you.

Assuming this tutorial post has well-acquainted aspiring to the complete requirement. If you want to download this tutorial in PDF format file, then please – click here to download PDF.

Also requesting, if you have any ideas or suggestions for me or you need some important blogs/Videos or guidelines related to SQL Server, Excel, WordPress, SEO, Website technologies then please feel free to write me on below comment section or you can go through the Contact Page. I will definitely come back to you with your desired requirements.

Hope this tutorial post was helpful for you and you liked very well, I am happy to serve you better. If you liked really this tutorial post, please don’t forget to share on social media like – Facebook, Whatsapp, LinkedIn, Twitter, Instagram, etc.

Leave a Reply