Introduction:

  • In this article we will explain how to use SQL Distinct keyword in SQL Server OR what is SQL Distinct Operator in SQL Server or how to select unique record in SQL Server with Example.


Description:

The SQL DISTINCT keyword is used with the SELECT statement to eliminate the duplicate records and return only unique records.

There may be a case when you have multiple duplicate records in a table. While getting such records, it will get only unique records instead of getting duplicate records.

The basic syntax of DISTINCT keyword to eliminate duplicate records is as follows:

 DISTINCT column1, column2
 FROM table_name 

The Following SQL Statement selects all Records from Student Table.

select Name,Mobile,address1 from Student

Result:

Use Distinct Keyword in SQL Server


DISTINCT Keyword

The following SQL statements remove all duplicate students. Above highlighted duplicate rows show once.

select distinct Name,Mobile,address1 from
Student

Result:

Use Distinct Keyword in SQL Server


I hope this will help you.


comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like