SQL Server – Deleting Duplicate Rows

Oh what a tangled web we weave when we don’t use unique constraints or primary keys…

Using some clever rules about deleting from a view (also applies to a common table expression).  You can delete from a view if the view only references one table.

WITH    cte(b, r)
AS (SELECT    Field1,
ROW_NUMBER() OVER (PARTITION BY Field1 ORDER BY Field1)
FROM      dbo.Table1
WHERE     Field1 IN (SELECT   Field1
FROM     dbo.Table1
GROUP BY Field1
HAVING   COUNT(*)>1))
DELETE FROM cte WHERE r > 1;

Part of the trick is to use Row_Number to make a distinction between the rows.  You can then delete anything that has a row number greater than 1 (a dupe)

Advertisement

Great Primer for Threading Basics in .Net

I stumbled across this article from one of my LinkedIn friends,  Threads in C#

It answered one of my questions about thread pooling in a very concise, easy to understand fashion.  It is a short article, but he then goes into the Task Parallel Library, something that I really enjoy.

If you are asking why should I care about this, I use the magic of Async/Await.  These are the fundamental technologies and techniques that they are built upon.

Keep in mind that not many people are experts in highly concurrent systems, I am not one of them either.  But hopefully by reading this article we will all be a little better in how we implement parallelism/concurrency.

Cheers!

SQL Server Performance Tuning For Developers

Chances are if you are reading this, you are a software developer.  Relax, I am one too, as well as a database administrator.  I spend a lot of time helping people to write code that is efficient or get the right results.  I want to share this post on SQL Database Tuning http://www.toptal.com/sql/sql-database-tuning-for-developers by Rodrigo Koch. It provides some really good advice, especially for beginners in the area.

Really hits the nail on the head though, keep it minimalistic. Only return what you need, it takes more time on the server and then the data has to go over the network.  He goes into some detail of how to troubleshoot slow queries and when to create indexes

 

Mocking in Python

An Introduction to Mocking in Python by Naftuli Tzvi Kay

This article is very insightful for covering mocking in Python.  In case you don’t know mocking is a technique for testing where you don’t want to use a particular object or set of objects.  For example, you might want to simulate database functionality while you are writing your test cases.

Hope you all find this useful, have a great day!

 

A ClickOnce gotcha – FIPS algorithms

If you are using FIPS, your ClickOnce applications might not work. I ran into this bug running BookSmarts, an application I wrote. Turned FIPS on and started receiving errors.

The issue is that enabling FIPS makes the mechanism that verifies the validity of ClickOnce applications fail every time.

The article, a very long one, can be found here: https://support.microsoft.com/en-us/kb/811833

Just keep this in mind if you are trying to support someone who is the odd ball out.

Note: Enabling/Disabling FIPS in Windows is done through the registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy\Enabled (DWORD)

1 is on, 0 is off

When changing this setting, it’s necessary to reboot the computer.

Cool tips and tricks for Google Chrome…

This is a decent post I put out there about Chrome on my businesses website but I figured all you WordPressers out there would enjoy skimming it too. I am going to make a series of these since people like them! More to come.

http://www.getbooksmarts.com/tips-tricksGet great speed from Chrome-and-news/google-chrome-productivity-tips-tricks

Google Chrome is starting to lose popularity.

browsersAre you using more than one browser to surf the web? If you are, you are not alone, according to market research the number is rising. Why? Some websites simply perform better on one browser than the others. No one browser is a clear winner on every website.

The reason being is software developers design and test websites more with the browser they prefer. This results in less thorough optimization with other browsers. Some websites just simply will not work on all browsers.

The result is having to remember which site works best on a particular browser, this can cause pain (just like trying to remember all of your passwords). Why do this to yourself?

The solution is to have a smart application do it for you with a minimum effort. BookSmarts imports your favorites and bookmarks from the browsers you use, and remembers to which browser they belong.

Just remember, it’s okay to use more than one browser.

booksmarts

Take a look at some of these statistics.

Today is your day to change.

How are you?

What are you doing?

When was the last time you seriously thought about that? Take a minute to think about that. If you are doing good, it feels great. If not, maybe you are ready for change.

Take a look at Maslow’s Hierarchy of Needs

At the base, these are basic things everyone needs, as you go up the pyramid, they are less necessary (but they do add to happiness. Now say you have one of those bottom items – physiological or safety – gets taken away, what happens? Well, everything above it quickly goes away.

Maslow's Hierarchy of Needs
Maslow’s Hierarchy of Needs

What can you do? You have to rebuild your pyramid. Lee Iacocca once said “The thing that lies at the foundation of positive change, the way I see it, is service to a fellow human being”. There is unconventional wisdom in this. Sometimes your perception of a situation is wrong, especially when you take some time and help someone who needs your help.

If you are truly convinced that is not the issue, replace what is causing your issue. So how do you do that? When do you do that? These are tough questions.

For me, anytime I have made a large change, I was scared and excited. I CHOSE to just be excited. The fear is a good thing, it keeps you on your toes, so you will succeed in what you do.

When do you make that change? I would say, when fear of the unknown is outweighed by the problem you are facing.

Here is a great podcast worth listening to on the subject.

The bottom line, take care of yourself. For every bad situation, there is a positive one to replace it.

Getting Reviewed.

The good news in my world is my software, BookSmarts, was reviewed. I didn’t really know it happened, but Softpedia reviewed it.

To tell you the truth, this sort of thing can be nerve-racking especially if you know ahead of time that they are going to review your work. In my case, I’ve been working on it for the past two years. The surprise moment when you see a review of your work makes time stand still and your heart starts beating harder.

When someone is working on something for two years without seeing a dime, it becomes their baby. I am now sure I know what the mother’s on Toddlers & Tiaras are experiencing. You have got this thing out there for the world to see, your baby, and people are criticizing or praising it. Trust me, as a parent, no one ever likes it if you call their baby ugly. Go ahead, I dare you to say that to a mom you know, see how it goes. You probably won’t be able to say that again without a lisp, because she knocked out your front teeth.

Luckily for me, I apparently have pretty baby, it got an excellent first review. It was an affirmation of my time and effort, as well as all those around me who have supported me through this intrepid endeavor. It is a reward, in a sense, for the effort. Yes, it is ultimately making money is proof of success, but this is a nice place to be in on the path to success.

BookSmarts Bookmark Manager Softpedia Rating

HAPPY HOLIDAYS!

MS Access – Remove Source Control

If you are like me, you love source control. I recently discovered you can use source control in Access via a plugin. However if you want to push it out to a client, how do you remove source control? What you do is a compact and repair of the database. It will ask you if you wish to remove source control from the new copy of the database, click yes and your should be good to go.