SQL Server–HOW-TO: quickly retrieve accurate row count for table

Recently, I’ve been involved in a very interesting project in which we need to perform operations on a table containing 3,000,000,000+ rows. For some tooling, I needed a quick and reliable way to count the number of rows contained within this table. Performing a simple SELECT COUNT(*) FROM Transactions operation would do the trick on…


SQL Server 2008 R2 – generating INSERT statements for a table

Learned something new today. Maybe it’s well-known, but new to me, you can just run “C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Publishing\1.4\SqlPubWiz.exe”. This nifty little tool can generate INSERT script very easily. Pictures tell the story 🙂


Reading MSMQ from within SSIS packages

Recently, I had to implement an SSIS package which imports some data into SQL Server from MSMQ. It turns out reading MSMQ from within an SSIS package is more difficult than it seems at first. I’ve documented how to get things working because I could find little other documentation. When reading data from MSMQ, there’s…


TFS 2010 beta 2: connecting from Visual Studio 2008

Connecting to Team Foundation Server 2010 beta 2 from Visual Studio 2008 is easy: from Team Explorer, type the full URL in the “add server” dialog, e.g.: http://mytfsserver:8080/tfs/defaultcollection Please ensure you’ve (re-)installed Visual Studio 2008 SP1. If you installed Team Foundation Client after applying SP1, reinstall SP1.


Active Directory – Adding a user to a group from a non domain-joined computer throws PrincipalException

When using the new System.DirectoryServices.AccountManagement namespace, one might be inclined (as was I) to use the following code to add a user to a group (exception and comments handling removed): using (GroupPrincipal groupPrincipal = GroupPrincipal.FindByIdentity( domainContext, System.DirectoryServices.AccountManagement.IdentityType.Name, groupName)) { if (groupPrincipal != null) { using (UserPrincipal userPrincipal = UserPrincipal.FindByIdentity( domainContext, System.DirectoryServices.AccountManagement.IdentityType.UserPrincipalName, UPN)) { if (userPrincipal…


Unity v1.2 – using enum values from configuration; writing and configuring a custom type converter

Recently, I used Unity v1.2, which in my opinion is a great product. I had difficulty, however, with the configuration for a scenario I encountered. I needed an enum value to be passed to a constructor. Trying as I might, there was no way Unity was accepting my typeAlias, as such: <unity> <typeAliases> <typeAlias alias=”contextType”…


WCF extensions: The type ‘x’ registered for extension ‘y’ could not be loaded.

Quick note: if you configure a custom extension in WCF, don’t forget to add it as a reference to your project. If you don’t configuration will run just fine, but at runtime, the following exception occurs: System.Configuration.ConfigurationErrorsException: The type ‘x’ registered for extension ‘y’ could not be loaded. (config information, line z)    at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[]…