Monthly Archives: March 2015

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

Originally posted on Prashanth Jayaram and Sreenivas Rao:
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…

Posted in SQL, T-SQL | Leave a comment

How to Replace Multiple Strings in a File using PowerShell

Replace the Data Source and Initial Catalog values of WebConfig.XML Content of XML file <Configuration ConfiguredType=”Property” Path=”\Package.Connections[ConnStaging].Properties[ConnectionString]” ValueType=”String”> <ConfiguredValue>Data Source=localhost;Initial Catalog=Stage;Integrated Security=SSPI; Connection Timeout = 10</ConfiguredValue> </Configuration> PARAM( [String]$DatabaseName=’DCTarget’, [String]$XML=’c:\webconfig.XML’, [String]$DatabaseServer=’DataCenterDB01′) [string]$db = ‘Catalog=’+ $DatabaseName [string]$dbs = ‘Source=’+ $DatabaseServer (Get-Content $XML) | … Continue reading

Posted in PowerShell, String handling | Tagged , , | Leave a comment

T-SQL – How to get the Financial Quarter details of a date field

declare @table table ( [Paid Date] date ) insert into @table values(‘20150102’),(‘20150512’),(‘20150830’),(‘20151231’),(‘20141230’) ;WITH Quarters AS ( SELECT Q = ‘Q1’, MonthBegin = 1, MonthEnd = 3 UNION SELECT Q = ‘Q2’, MonthBegin = 4, MonthEnd = 6 UNION SELECT Q … Continue reading

Posted in SQL | Tagged , , , , | 4 Comments