Quantcast
Channel: Sql Server – SqlHints.com
Browsing all 130 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

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 Article


Image may be NSFW.
Clik here to view.

EXECUTE/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 Article


Image may be NSFW.
Clik here to view.

SINGLE_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 Article

Image may be NSFW.
Clik here to view.

How 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 Article

Image may be NSFW.
Clik here to view.

Cannot 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 Article


Image may be NSFW.
Clik here to view.

Truncate 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 Article

Image may be NSFW.
Clik here to view.

A-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 Article

STUFF 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 Article


ERROR: ‘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 Article


Image may be NSFW.
Clik here to view.

How 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 Article

Image may be NSFW.
Clik here to view.

How 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 Article

Image may be NSFW.
Clik here to view.

How 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 Article

Image may be NSFW.
Clik here to view.

How 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 Article


Image may be NSFW.
Clik here to view.

How 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 Article

Image may be NSFW.
Clik here to view.

How 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 Article


Image may be NSFW.
Clik here to view.

Looping 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 Article

Image may be NSFW.
Clik here to view.

WHILE 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 Article


Image may be NSFW.
Clik here to view.

Msg 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 Article

Image may be NSFW.
Clik here to view.

Must 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 Article

Image may be NSFW.
Clik here to view.

How 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
Browsing all 130 articles
Browse latest View live


Latest Images