Friday, September 11, 2020

HOW TO USE ORDER BY IN SQL SERVER

Order By: When we execute select statement to fetch the records or result sets from table in SQL Server then all records doesn't come in a sorting order. So at that time, we use Order By clause to sort the records or result sets in ascending and descending order.

The Order By clause is used into the SELECT Statement or SELECT Query.

The Order By clause is used after the WHERE Condition in SELECT Statement or SELECT Query.

Sometimes, the records or result sets fetch from table by default in ascending order. 

We can sort records or result sets in ascending and descending order by using Order By ASC|DESC.

Order By ASC: The Order By ASC clause is used to sort the records or result sets in ascending order. The syntax is as below:

SELECT * FROM TABLE WHERE CONDITION ORDER BY COLUMN

                           OR

SELECT * FROM TABLE WHERE CONDITION ORDER BY COLUMN ASC

Here, we have an EMPLOYEE table and we will apply sorting in ascending order into the select statement. Please see the below screenshot for further clarification.


Order By DESC: The Order By DESC clause is used to sort the records or result sets in descending order. The syntax is as below:

SELECT * FROM TABLE WHERE CONDITION ORDER BY COLUMN DESC

Here, we have an EMPLOYEE table and we will apply sorting in descending order into the select statement. Please see the below screenshot for further clarification.


                 - - - - - - Cheers, Happy to Help! - - - - - - 

 

Sunday, September 6, 2020

DIFFERENCE BETWEEN MYSQL AND MS SQL SERVER

MYSQL: The MYSQL is an open source Relational Database Management System or RDBMS and it is developed by ORACLE now. There are some points mentioned that it differs that MS SQL SERVER. These are as follows:

MYSQL is an open source and it is freely available.

MYSQL  is more preferred and useful for PHP and open source based applications or projects.

MYSQL can run smoothly on several operating systems like Windows, Linux and Mac operating system.

MYSQL is an open source RDBMS and it saves data in tabular format.

MYSQL supports PHP, C++, JAVA, Python, Visual Basic Delphi etc. It also can additionally supports Perl, Scheme, Tcl, Haskel and Eiffel.

MYSQL blocks the database while backup data by extracting all data as sql statements.

MYSQL follows ANSI standards with some customization added with some functions and features.

MYSQL uses sql language to query the database.

MYSQL expects less amount of operational storage space.

When the query is running then it doesn't allow users to kill or cancel a query.

MS SQL SERVER: The MS SQL SERVER is also an open source Relational Database Management System or RDBMS and it is developed by Microsoft. There are some points mentioned that it differs that MYSQL. These are as follows:

MS SQL SERVER is an open source RDBMS  and it is not freely available.

MS SQL SERVER  is more preferred and useful for db products in Windows based environments.

MS SQL SERVER is mainly run on Windows.

MS SQL SERVER  is an open source RDBMS and it also saves data in tabular format.

MS SQL SERVER also supports PHP, C++, JAVA, Python, Visual Basic Delphi etc.

MS SQL SERVER doesn't blocks the database while backup data. It makes backup and restore huge faster.

MS SQL SERVER also follows ANSI standards with some customization added with some functions and features.

MS SQL SERVER is a query language and it creates and manipulate objects in RDBMS.

MS SQL SERVER expects large amount of operational storage space.

When the query is running then users have to kill the entire process to stop sql query execution.


            - - - - - - Cheers, Happy to Help! - - - - - - 



DIFFERENCE BETWEEN CHAR AND VARCHAR IN SQL SERVER

CHAR:  The  CHAR datatype is a fixed length data type in sql server. It is used to store fixed length type of string data or character strin...