LEFT, RIGHT and SUBSTRING in SQL Server

In this tutorial, you’ll see how to apply LEFT, RIGHT and SUBSTRING in SQL Server. In particular, you’ll observe how to extract specific characters: 8 scenarios of LEFT, RIGHT and SUBSTRING in SQL Server For each of the scenarios to be reviewed, the ultimate goal is to extract only the digits within the strings. For … Read more

Case Statement using SQL

Here are 3 different ways to apply a case statement using SQL: (1) For a single condition: Copy CASE WHEN condition_1 THEN result_1 ELSE result_2 END AS new_field_name (2) For multiple conditions using AND: Copy CASE WHEN condition_1 AND condition_2 THEN result_1 ELSE result_2 END AS new_field_name (3) For multiple conditions and results: Copy CASE … Read more

How to Create a Table in SQL Server

In this tutorial, you’ll see the complete steps to create a table in SQL Server. An example is also reviewed for demonstration purposes. Steps to Create a Table in SQL Server Step 1: Create a database If you haven’t already done so, create a database where the table will be stored. For example, you may … Read more

How to Create or Drop a Database using SQL

To create a database using SQL: Copy CREATE DATABASE your_database_name; To drop a database using SQL: Copy DROP DATABASE your_database_name; Example of creating and dropping a database using SQL Let’s create a database called the “test_database” using this syntax: Copy CREATE DATABASE test_database; And if you want to drop that database, then use: Copy DROP … Read more