Category: SQL

Use of UPDATE Statement in SQL

Use of UPDATE Statement in SQL: (1) “UPDATE” statement is used to modify records. (2) Syntax of “UPDATE” statement is: UPDATE table_nameSET column1 = value1, column2 = value2, … column = valueNWHERE condition; WHERE clause is used to specify which record should be modified. (3) Let’s take an example to update/modify records in the Vendor table as shown. …

Use of STORED PROCEDURES in SQL

Use of STORED PROCEDURES in SQL: (1) “STORED PROCEDURES” is a type of function in SQL Query which is used in other queries again and again. You can also pass parameters so that it gives results according to the given parameter. (2) Syntax of “STORED PROCEDURE” statement is: CREATE PROCEDURE PROCEDURE_NAMEASSQL STATEMENTGO; (3) Let’s take an …

Use of GROUP BY Statement in SQL

Use of GROUP BY Statement in SQL: (1) “GROUP BY” is used to group rows having the same value in a column (grouping of records on the basis of column). (2) “GROUP BY” is mainly used with the combination of COUNT(), MAX(), MIN(). (3) Syntax of “GROUP BY” statement is: SELECT Col1, Col2, …ColNFROM table_name1GROUP BY Col2; …

Use of UNION and UNION ALL Operator in SQL

UNION and UNION ALL Operator in SQL: (1) “UNION” & “UNION ALL” operators are used to combine two SELECT statement results. (2) The difference between “UNION” and UNION ALL” is that “UNION” select only unique values from two columns having the same datatype and same sequence whereas “UNION ALL” select all values whether it is duplicate …

How to Take BACKUP from SQL Database

Take BACKUP from SQL Database: (1) Open SQL Management studio, as shown. (2) Run as administrator, as shown. (3) After that SQL server window open and select server and enter User Id & Password (*User id & Password is required when SQL server is open as SQL Server Authentication. If open as Window Authentication then User …

Use of ALIASES operator in SQL

Use of ALIASES operator in SQL: (1) “ALIASES” operator is used to give a temporary name to column and table. Aliases are mostly used to make column names more readable. (2) Syntax of “ALIASES” statement is: SELECT column1 AS alias_name, column2 AS alias_name, …FROM table_name (3) Let’s take an example to give a temporary name to a column …

Use of BETWEEN Operator in SQL

Use of BETWEEN Operator in SQL: (1) “BETWEEN” operator is used to get values within the specified range. (2) Syntax of “BETWEEN” statement is: SELECT column1, column2, …FROM table_nameWHERE column1 BETWEEN value1 AND value2; (3) Let’s take an example to get records according to the “No.” column is equal to the assigned values as shown. (4) Select the …

Use of IN operator in SQL

Use of IN operator in SQL: (1) “IN” operator is used where multiple conditions are executed. It is a shortcut of the “OR” operator. It is used with the “WHERE” clause. (2) Syntax of “IN” statement is: SELECT column1, column2, …FROM table_nameWHERE column1 IN (value1,value2… valueN); (3) Let’s take an example to get records according to the “Country …

Use of SELECT TOP Statement in SQL

Use of SELECT TOP Statement in SQL: (1) “SELECT TOP” statement is used to get a specific number of records. (2) Syntax of “SELECT TOP” statement is: SELECT TOP number column1, column2, …FROM table_name; (3) Let’s take an example to get specify records from the Vendor table as shown. (4) Select the database in the SQL server and click …

Use of CREATE DATABASE Statement in SQL

Use of CREATE DATABASE Statement in SQL: (1) “CREATE DATABASE” statement is used for creating a new database. (2) Syntax of “CREATE DATABASE” statement is: CREATE DATABASE databasename;CREATE DATABASE databasename ON PRIMARY (Name =N’Databasename_Data’,FILENAME= N’Pathe’)LOG ON (Name = N’Databasename_Log’,FILENAME= N’Pathe’); (3) Let’s create two databases in the below examples. One is created in by default path …