How to check if a function exists in Sql Server?

How to check if a function exists in Sql Server?

When creating a function dynamically, it is a best practice to perform a check if a particular function you want to create has already existed in a database. To perform a check of an existing function you can use the following EXISTS keyword. If the function does not exist then perform a creation of the function.
How to sort comments with nested replies in SQL Server?

How to sort comments with nested replies in SQL Server?

Do you need to sort comments with nested replies in SQL Server? Well this can be easily done by combining the same table using the UNION ALL join to populate the comments content. There is a trick to used to sort the comments which use the combination of a record ID field with the row number index.
How to check if a table exists in SQL server?

How to check if a table exists in SQL server?

Before running an SQL script to create a table dynamically, it would be a good step if you perform a checking if a table already exists. If it does, you may want to skip creating the table otherwise you will get an error exception.
How to add new column to table in SQL Server?

How to add new column to table in SQL Server?

In this tutorial, you will learn how to add new columns to table in SQL Server. Let's say we have a table called table_product and we want to add two columns named ProductCode and Description.