Monthly Archives: January 2015

T-SQL – Find Number of Rows of Database(s) tables Using Undocumented Procedure – sp_MSforeachdb and sp_MSforeachtable

On Technet forum, Op was looking for a way to get table cardinality for all databases in an instance.  There are many ways to get the result. This post gives you an idea and SQL in which undocumented SP’s being called  “sp_MSforeachdb and … Continue reading

Posted in sp_MSforeachtable, SQL, T-SQL | Tagged , , , , , , , , , , | 1 Comment

SQL- Querying XML attributes from XML Column

Read XML column attributes in to two columns DimType and Dimvalue  from the below example also retrieve the data matching values[DimTypes (WIDTH or Height)]. ‘<dimensions> <dimension name=”width”  value=”12.77″/> <dimension name=”height”  value=”0.14″/> <dimension name=”depth”      value=”12.92″/> </dimenstions>’ Download SQL :-  https://gallery.technet.microsoft.com/SQL-Querying-XML-f700bbb0 … Continue reading

Posted in SQL XML | Tagged , , , | Leave a comment

T-SQL to Display Weekends Between two Dates

Different ways to find the weekend between two given dates. The SQL requires @begindate and @endate paramteters to be entered in the below SQL Download T-SQL WeekendBetweenTwoValidDates DECLARE @beginDate Date=’20150101′, @endDate Date=’20150131′ DECLARE @Calendar Table (CalendarDate Date Primary key, IsWeekend Bit) … Continue reading

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

T-SQL – How to find Next Business day from a given date

There are many methods to find next business day. One common way is to use of calendar table.  This post is to get an output using T-SQL Or UDF function. Download T-SQL  NextBusinessDay The details are given below The script can be executed by … Continue reading

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

SQL – Split delimited columns using XML Or UDF function

The requirement is to convert the delimited column into rows Input data and required output details are given below Eno Ename Esloc EDept 1 ABC NJ 10,20,30,40,50 Output:- Eno Ename Esloc EDept 1 ABC NJ 10 1 ABC NJ 20 … Continue reading

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