Category: SQL

Take Database Backup via SQL Query in SQL Server

Take Database Backup via SQL Query in SQL Server: (1) “BACKUP DATABASE” statement is used to take a full backup of an existing database. (2) Syntax of “BACKUP DATABASE”& DIFFERENTIAL statement is: BACKUP DATABASE database_nameTO DISK = ‘PathOfFile’; BACKUP DATABASE database_nameTO DISK = ‘PathOfFile’;With DIFFERENTIAL (3) Select the database in the SQL server and click on the …

Create Database via query in SQL Server

Create Database via query in SQL Server: (1) “CREATE DATABASE” command is used to create a new database in SQL Server. (2) Syntax: Create Database NameOfDataBase; (3) Let’s create a database via query. Select the database in the SQL server and click on the “New Query” button as shown. (4) After that new query editor open …

Use of INNER JOIN in SQL Server

Use of INNER JOIN in SQL Server: (1) “INNER JOINS” is used to combine data from two or more tables, according to the related column similarity. It returns records having the same value in both tables. (2) Syntax of “INNER JOIN” statements are: SELECT Col1, Col2, …ColNFROM table_name1INNER JOIN table_name2ON table_name1.col1 = table_name2.col1; (3) Let’s take an …

Types of JOINS Statement in SQL Server

Types of JOINS Statement in SQL Server: (1) “JOINS” is used to combine data from two or more tables, according to the related column similarity. (2) Different types of JOINS are- INNER JOIN LEFT JOIN RIGHT JOIN FULL JOIN SELF JOIN (3) INNER JOIN: Return records having the same value in both tables. (4) LEFT JOIN: …

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 …