Category Archives: T-SQL

TSQL Challenge

On the series of TSQL Challenges, here is the next challenge. The requirement is to group the same parent when they have same child information. Below is the sample source records where the expectation is to merge the Usage by … Continue reading

Posted in T-SQL | Tagged , , , , , , , , , , | Leave a comment

TSQL Challenge

On the series on SQL challenges, below is the next puzzle/challenge and the requirement is to find out the person name who has both mango and apple Table 1: @Person contains Person NameTable 2: @PersonFruits contains the available fruits per … Continue reading

Posted in SQL SERVER 2008, T-SQL | Tagged , , , , , | Leave a comment

TSQL : Update columns with different values randomly

Continuing the series on SQL challenges. I came across a requirement from an online Tech forum where the request was to perform an update on a table column with a sequence of values randomly I have tried to write a … Continue reading

Posted in SQL SERVER 2008, T-SQL | Tagged , , , | 1 Comment

T-SQL : Gaps and Islands Problem – 2

There are lot of ways to find the gaps in a sequential numbers, and some of them are listed below. I have posted some 3 methods to achieve the expected. The goal is to find the gaps between the sequential … Continue reading

Posted in T-SQL | Tagged , , , | Leave a comment

T-SQL : Delete duplicates in a table using Query

Following are the queries that will delete all available duplicates in a table, please refer the query below [sourcecode language=”sql” wraplines=”false”] Declare @Duplicates table (Name nvarchar(50), Age int, BookingID int) insert into @Duplicates select ‘Dinesh’,26,145 union all select ‘Latheesh’,26,142 union … Continue reading

Posted in T-SQL | Tagged , , , , | 8 Comments

T-SQL : Query to fetch report subscription details from SSRS

In SSRS, to find who has created/modified the report subscription without using the management site, the following query can be used, [sourcecode language=”sql” wraplines=”false”] select reps.Name as ReportName ,usr.UserName createdby from Subscriptions subs join Catalog reps on subs.Report_OID = reps.ItemID … Continue reading

Posted in T-SQL | Leave a comment

T-SQL : Get all folder names from SSRS Reports Manager/Server

We all know, we can query the report server database and get very useful information, such as reports details, directory and schedules etc. This particular thread belongs to one such category, this query will provide you all available folders from … Continue reading

Posted in T-SQL | Tagged , , , , , , , | Leave a comment

T-SQL : Get count of all tables in a database

The following query will list the count of records in all tables of a database. These queries are based on CURSORS, Query 1: Query to get individual results, [sourcecode language=”sql” wraplines=”false”] DECLARE @SQL VARCHAR( max ), @TableName VARCHAR (255 ), … Continue reading

Posted in T-SQL | Tagged , | Leave a comment

T-SQL : List of scheduled reports in SSRS

The following query will list all the available report subscriptions in SSRS. The reportserver database basically holds all metadata information [reports, users, schedules, roles etc] of all reports and thereby, querying the same will provide us a lot of useful … Continue reading

Posted in T-SQL | Tagged , , , , , , | Leave a comment

T-SQL : How to get columns names of all tables

How to get columns names from all tables of a database ? The query should return all the columns of all tables in a particular database, in a order like how it is stored in the tables The following queries … Continue reading

Posted in T-SQL | Tagged , , , , , | Leave a comment