Tuesday, September 25, 2012

Removing duplicate rows from a SQL server DB

I've been working on data imports lately and have run into this issue several times. If you data isn't clean when you import from a spreadsheet or csv or wherever, you can end up with duplicate rows in your tables. This isn't a really big deal if the rows have differing keys, but if ALL the data is identical, including the keys, then how do you delete the extra rows?

It turns out that the answer is pretty simple. Write your query to delete the rows but before you run it, set the rowcount to 1, this will prevent SQL server from performing your query on more than a single row. Don't forget to set rowcount back to 0 afterwards, or all your subsequent operations will only return 1 row which, at least for me, would be really frustrating :)

Here's a nice explanation of the process from Microsoft: http://support.microsoft.com/kb/139444.

Thursday, September 20, 2012

Adding Labels/Arbitrary Text to MSCRM 2011 Forms

So, you say you want to add your own text to a MSCRM form huh? Well, Microsoft doesn't make it immediately obvious how to perform such a seemingly innocuous task. I was able to find a blog post here which did the trick: http://blogs.infinite-x.net/2011/05/20/adding-form-labels-using-html-web-resources/

Thanks to "Chris C" clarifying how to re-style the WebResource so that it takes up only the amount of space that you want it to take up instead of what MSCRM does by default.

I've taken the liberty of reproducing his comment below in case the blog post eventually goes "poof".


Chris C says:
Hmm, looks like the HTML messed up in my last post! I'll remove any formatting which is going to mess it up this time :)
The reason you need to specify 2 rows is that the CSS isn't removing all the margins around the text and as such it's taking up more space than it appears.
I can successfully use 1 row with the following CSS changes:

body style="border: 0px 0px 0px 0px;
margin:0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
font-family: Segoe UI, Tahoma, Arial;
font-size: 11px;
font-weight: bold;
background-color: #f6f8fa;"
Hope that helps!