SQL SERVER – Validate Field For DATE datatype using function ISDATE()

This article is based on the a question from Jr. Developer at my company. He works with the system, where we import CSV file in our database. One of the fields in the database is DATETIME field. Due to architecture requirement, we insert all the CSV fields in the temp table which has all the fields VARCHAR. We validate all the data first in temp table (check for inconsistency, malicious code, incorrect data type) and if passed validation we insert them in the final table in the database. Let us learn about ISDate function in this blog post.

Read More

SQL SERVER – Result of EXP (Exponential) to the POWER of PI – Functions Explained

SQL Server can do some intense Mathematical calculations. Following are three very basic and very necessary functions. All the three function does not need explanation. I will not introduce their definition but will demonstrate the usage of function. SELECT PI() GO SELECT POWER(2,5) GO SELECT POWER(8,-2) GO SELECT EXP(99) GO…
Read More

SQL SERVER – Explanation of WITH ENCRYPTION clause for Stored Procedure and User Defined Functions

This article is written to answer following two questions I have received in last one week. Questions 1) How to hide code of my Stored Procedure that no one can see it? 2) Our DBA has left the job and one of the function which retrieves important information is encrypted,…
Read More

SQL SERVER – Repeate String N Times Using String Function REPLICATE

I came across this SQL String Function few days ago while searching for Database Replication. This is T-SQL Function and it repeats the string/character expression N number of times specified in the function. SELECT REPLICATE( ' https://blog.sqlauthority.com/ ' , 9 ) This repeats the string https://blog.sqlauthority.com/ to 9 times in…
Read More

SQL SERVER – Explanation and Comparison of NULLIF and ISNULL

Explanation of NULLIF
NULLIF ( expression , expression )

Returns a null value if the two specified expressions are equal. NULLIF returns the first expression if the two expressions are not equal. If the expressions are equal, NULLIF returns a null value of the type of the first expression. NULLIF is equivalent to a searched CASE function in which the two expressions are equal and the resulting expression is NULL.

Read More
Exit mobile version