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…

8

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 🙂

3

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…

0

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.

0

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…

3

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”…

1

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[]…

0

Unit testing: COM object that has been separated from its underlying RCW cannot be used

Let’s say you’re writing unit tests for code which uses COM objects. You want some initialization and some cleanup to be done. So you set up your test: private static MyStore store; [ClassInitialize()] public static void MyClassInitialize(TestContext testContext) { store = new MyStore(“some value”); } [ClassCleanup] public static void MyClassCleanup() { store.DoWork(someArgument); } However, as…

2

Office 2010 Development – Outlook main window ribbon ID

I’m currently writing an Outlook add-in and I’m looking into getting this compatible with both Office 2007 and Office 2010. One of the new features in Outlook 2010 is the main window Ribbon. Using VSTO, you can create your own Ribbon, which can be automatically merged with default Ribbons by setting the correct OfficeId property…

1

PrintMonitor – A C# print spooler monitor

Recently, a colleague of mine had a requirement of getting information on the number of pages being printed by users. Monitoring a printer is done by calling FindFirstPrinterChangeNotification, waiting for the returned WaitHandle to be signaled and then calling FindNextPrinterChangeNotification to see why the handle got signaled and act accordingly. Sadly, there don’t seem to…

0