How to add Hours, Minutes, Seconds to a DateTime in Sql Server
In this article we will discuss on How to add Hours, Minutes, Seconds to a DateTime in Sql Server? You may also like to read the following other popular articles on Date and Time in Sql Server: How to...
View ArticleEXECUTE/EXEC Stored Procedure/Function Statement may raise an error like:...
In this article let us go over the scenarios which causes an error like the below one and how to solve it. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ‘)’.’ Basically, we will get the...
View ArticleSINGLE_USER, RESTRICTED_USER and MULTI_USER user access modes in SQL SERVER
In this article let us go over the following aspects of the database user access modes: What are the different database user access modes and their meanings? How to SET database to different user...
View ArticleHow to check if Temp table exists in Sql Server?
This article shows how in Sql Server we can check the existence of Temporary Table. To demonstrate this let us first create a Temporary Table with name #TempTable. --Create Temporary Table CREATE TABLE...
View ArticleCannot truncate table ‘xyz’ because it is being referenced by a FOREIGN KEY...
In this article we will discuss on when we get the error like below in Sql Server and how to resolve it. Msg 4712, Level 16, State 1, Line 1 Cannot truncate table ‘Customer’ because it is being...
View ArticleTruncate all/all except few/specified Tables of a Database in Sql Server
This article presents how we can generate a script to truncate all tables/all tables except few specified tables/specified tables of a Database in Sql Server. One of major the problem with table...
View ArticleA-Z of Filtered Indexes with examples in Sql Server
Filtered Index (i.e. Index with where clause) is one of the new feature introduced in Sql Server 2008. It is a non-clustered index, which can be used to index only subset of the records of a table. As...
View ArticleSTUFF Function in Sql Server
This article explains the string function STUFF with extensive list of examples. Description: STUFF function adds the Addon_String into the Source_string at the specified Start position in the...
View ArticleERROR: ‘INT’ is not a recognized CURSOR option -Sql Server
In this article will demonstrate when we get an error like below and how to resolve it. Msg 155, Level 15, State 2, Line 1 ‘INT’ is not a recognized CURSOR option. WHEN WE GET THIS ERROR: We get an...
View ArticleHow to STOP or ABORT or BREAK the execution of the statements in the current...
Sometime back came across a scenario where I needed to STOP or ABORT the execution of the next statements in the current batch and in the subsequent batches based on some condition. Experimented...
View ArticleHow to replace NULL value by 0 in the Dynamic Pivot result – Sql Server
For the previous articles PIVOT and UNPIVOT in Sql Server and Dynamic PIVOT in Sql Server, recieved couple of comments requesting: how to replace NULL value by 0 in the PIVOT result?. In this article...
View ArticleHow to get month name from date in Sql Server
Many a times we come across a scenario where we may need to get Month name from Date in Sql Server. In this article we will see how we can get Month name from Date in Sql Server. Approach 1: Using...
View ArticleHow to get Day or Weekday name from date in Sql Server
Many a times we come across a scenario where we may need to get Day/Weekday name from Date in Sql Server. In this article we will see how we can get Day/Weekday name from Date in Sql Server. Approach...
View ArticleHow to Subtract Days, Weeks, Months, Quarters or Years from Date in Sql Server
In this article we will discuss on How to Subtract Days, Weeks, Months, Quarters or Years from DateTime in Sql Server? You may also like to read the following other popular articles on Date and Time in...
View ArticleHow to rename column name in Sql Server
Many times we come across a scenario where we need to rename / change the existing table column name. We can use the SP_RENAME system stored to change/rename the table column name. In this article we...
View ArticleLooping through table records in Sql Server
This article lists out extensive list of example scripts for looping through table records one row at a time. This article covers the examples for the following scenario’s for looping through table...
View ArticleWHILE loop in Sql Server
WHILE loop is the looping construct supported by Sql Server. Sql server doesn’t have for…loop, do…while loop etc, but with WHILE loop we can simulate these missing looping constructs behaviour. This...
View ArticleMsg 128, Level 15, State 1, Line 1 The name “%.*s” is not permitted in this...
This article lists out the extensive list of scenarios in which we get the following error message and how to solve it. Error Message: Msg 128, Level 15, State 1, Line 1 The name “%.*s” is not...
View ArticleMust declare the scalar variable – Error Message 137
This article lists out the extensive list of scenarios in which we get the following error message and how to resolve it. Error Message: Msg 137, Level 15, State 1, Line 1 Must declare the scalar...
View ArticleHow to check if a record exists in table in Sql Server
Frequently, we come across a scenario where we need to check the existence of a record and based on it perform some action. This article explains how to use the EXISTS clause to check the existence of...
View Article