How to Split comma or any other character delimited string into a Table in...
Many a time we come across a scenario where we pass a comma or any other character delimited string to stored procedure and in stored procedure we want to fetch data from other tables based this...
View ArticleHow to get all the Tables with or without an Identity column in Sql Server?
This article provides the script to find all the Tables with or without an Identity column Tables with Identity column We can write a query like below to get all the Tables with Identity column: SELECT...
View ArticleHow to get Yearly data in Sql Server
This article demonstrate how to get yearly data in Sql Server in different formats as shown in the below image. Here Sales table data is presented in two different yearly aggregated sales data formats....
View ArticleHow to get Daily data in Sql Server
This article demonstrate how to get daily data in Sql Server in different formats as shown in the below image. Here Sales table data is presented in two different daily aggregated sales data formats....
View ArticleHow to get Hourly data in Sql Server
This article demonstrate how to get hourly data in Sql Server in different formats as shown in the below image. Here Sales table data is presented in two different hourly aggregated sales data formats....
View ArticleHow to check if a VIEW exists in Sql Server
Many a times we come across a scenario where we need to execute some code based on whether a View exists or not. There are different ways of identifying the View existence in Sql Server, this article...
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 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 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 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 get Monthly Data in Sql Server
This article demonstrate how to get Monthly data in Sql Server in different formats as shown in the below image. Here Sales table data is presented in two different Monthly aggregated sales data...
View ArticleHow to get Quarterly Data in Sql Server
This article demonstrate how to get quarterly data in Sql Server in different formats as shown in the below image. Here Sales table data is presented in two different quarterly aggregated sales data...
View ArticlePRINT/SELECT Statement messages within WHILE LOOP or BATCH of statement is...
Are you facing the problem where the PRINT/SELECT statements messages are not being displayed like the one’s explained in the below two scenario’s? Let us go through these scenario’s and also see how...
View ArticleHow to Check if a String Contains a Substring in it in Sql Server
We can use the CHARINDEX() function to check whether a String contains a Substring in it. Name of this function is little confusing as name sounds something to do with character, but it basically...
View ArticleHow to get All the Tables which are Modified in last few days in Sql Server?
We can write a query like below to get the all the Tables which are modified using an ALTER statement in last 10 days. A Table is also considered as modified when an Index on the table is Created or...
View ArticleHow to get all the records which contain double byte data or all the records...
In NVARchar DataType column we can store both Single byte and Double byte data. Many a times we want to know how many records have Single byte or Double byte data. Let us understand this with an...
View ArticleJoining Two Tables without any Common Column between them – Sql Server
A friend of mine was needed a script where he wanted a One-to-One record mapping between two tables records which don’t have any common column between them for joining. That is he wanted to match the...
View ArticleHow to get all the Tables with or without Non-Clustered Indexes in Sql Server?
We can write a query like below to get all the Tables without any Non-Clustered indexes: --List all the Tables with NO Non-Clustered Indexes SELECT Name 'Tables without any Non-Clustered Indexes' FROM...
View ArticleHow to find all the tables with no indexes at all in Sql Server?
We can write a query like below to get all the Tables in the Database that don’t have any indexes: SELECT Name 'Tables without any Indexes' FROM SYS.tables WHERE...
View ArticleHow to get all the Tables with or without Primary Key Constraint in Sql Server?
We can write a query like below to get all the Tables with no Primary key constraint: SELECT T.name 'Table without Primary Key' FROM SYS.Tables T WHERE OBJECTPROPERTY(object_id,'TableHasPrimaryKey') =...
View Article