Monday, August 31, 2020

HOW TO USE LIKE OPERATOR IN SQL SERVER

 LIKE Operator: The LIKE operator is used to find a specified pattern to filter rows or records from a table.It is most widely used into the WHERE clause with SELECT, DELETE and UPDATE sql statements.

The two wildcards are often used with LIKE operator. These are as below:

a) % or Percent Sign

b) _ or Underscore Sign

a) % or Percent Sign: It represents 0, 1, or multiple characters.

b) _ or Underscore Sign: It represents a single character. 

The syntax of  LIKE operator is as follows:

SELECT * FROM TABLE WHERE COLUMN LIKE '%R%'

So, here we have a Employee table with list of records.


Now, we will use a LIKE operator to filter records from Employee table.

1. %SACH% : It fetches all the records from an employee table that have SACH character in any position. Please see the screenshot as belows:



2. R% : It fetches all the records that start with R character from an employee table. Please see the below screenshots.


3. %R : It fetches all the records that ends with R character from an employee table. Please see the below screenshots.


4. _R% : It fetches all the records from an employee table that have R character is in second position. Please see the below screenshots.


5. R_% : It fetches all the records from an employee table that have R character is in first position. Please see the below screenshots.


6. R%H : It fetches all the records from an employee table that have R character is in first position and H character is in last position. Please see the below screenshots.



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


Monday, August 24, 2020

HOW TO CREATE DB BACKUP OF AN EXISTING DATABASE IN SQL SERVER

Step 1: Select an existing database and right click on it and select Tasks and then select Backup... option.

Step 2: After click on the Back Up... option, you will see next window i.e.

Here, you will remove destination backup file path by click on remove button or you can create backup file in above selected backup file path.

Step 3: After remove the selected file path, you can save backup file at your specified location. You will see into the below screenshot in which i will create backup file with named as "TESTDB.bak" in DB Backup direcory which is located in C Drive.

Step 4: Next, you have to click OK button.

Step 5: After click on OK button, you backup file will be created successfully. Please see the below screenshot:

                - - - - - - 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...