Category: SQL Server

What is the Difference between varchar and nvarchar in SQL Server?

The SQL Server has the data type varchar and nvarchar . What is the main difference between the both ? Let’s explore it in this article. What is the Difference between varchar and nvarchar in SQL Server? varchar is a variable length and non-unicode data type which can take the 8-bit codepage. The collation of the database identifies which of the code page should be…

How to Update From Select Statement in SQL Server ?

Below is a sample query that demonstrates how to update a table by getting the data from the select query in SQL Server. Assume that there are 2 tables AbundantCodeEmployee and AbundantCodeDepartment which contains the id . The id(in department) in this example refers to the department head . The columns “DepartmentName” is updated in the query based on the value retreived  . How to Update From…

How to Add a Column with Default Value to Existing Table in SQL Server ?

Looking to add a column with default value to an existing table in SQL Server ? Below is an example and sample Data Definition Language Query for achieving the same. How to Add a Column with Default Value to Existing Table in SQL Server ? Assume that the table name is “ACEmployee” which already exists and you want to add a new column called “Status”…

How to Check if the table exists in SQL Server ?

Do you want to know if the table exists in a in SQL Server ? . Below is a sample query that lets you know if the table exists or not. How to Check if the table exists in SQL Server ? Assume that the table name is Employee , run the below query to know if the table exists in the SQL Server or…

How to Enable All Constraints back in the Database in SQL Server ?

In one of the articles , we explained How to Disable All Constraints in the Database temporarily in SQL Server ? , let’s look at the option of how to enable back the constraints in the SQL Server Database. How to Enable All Constraints back in the Database in SQL Server ? Below is a sample query that enables all the constraints back to the…

Equivalent of IF Statement in SQL Server

There are times when you want to perform conditional checks within a SQL Query in SQL Server . Below is a sample Query that demonstrates how to do it. Equivalent of IF Statement in SQL Server Assume that the Employee table contains a column called “Designation” and we might want to show a value 1 if the designation is SSE else show 0 . You…