July 2006 Entries


SQL comparison

One of the tools I find lacking in the industry is a good sql comparison utility. I have tried some free ones that really seem to not work very well at all. Commercially I have found that red-gate and adept's programs quite good but I am cheap. Has anyone found a good tool to compare to databases to each other that is free? Or would anyone be interested in starting an open source project to do this with me?

SQL Boolean Queries

The other night at edmug Richard Campbell presented some good SQL Querying Tips & Techniques. A lot of them were about sql 2005 which was nice to see (espeically using Common Table Expressions which are quite handy in the case of recursion). The coolest thing I found was in regards to a cross tab query. The example used was to get sales amount by month for each employee. As you can see in the following example this is done with a lot of subqueries that builds a hideous execution plan.SELECT Salespeople.Salesperson, SUM(S1.Quantity*S1.Price) AS Total,   (SELECT SUM(S2.Quantity*S2.Price) FROM Sales AS...

Security Series: Multi-Role security using windows impersonation

I have finally finished my video on using windows impersonation and having multiple security roles throught the application. I feel that the worst habbit most developers have is having only one user account that has access to the entire database. In the video I create 2 windows users (a regular user and an administrator) then grant them rights to the database and certain objects within the database. I also talk about how to have the website connect to the database using a trusted connection under the two roles (so no passwords stored in the config file which is my other...

RansomWare

I read an interesting article this morning about a new scary trend called RansomWare. RansomWare is esentially a virus that infects your system and then encrypts your files. You are then notified of this and asked to pay a sum to the author in order to release the files on your computer. Kaspersky Labs has warned that if a large enough encryption key is used the data will be uncrackable due to the limits of computing power. I can really see this taking of as cyber crime as an industry is rapidly growing (and why not... there are what 3...

Returning extra data in a stored proc

    Today I was asked how to return an error code from a database along with other data. While I try to sheer away from error codes from the database and do my validation / logic in the business / data layers this still is necessary. Most people I have worked with have no idea that sql2000 (and 2005) support output parameters which can be quite usefull. CREATE PROCEDURE GetCustomers ( @ErrorCode int OUTPUT )ASSELECT * FROM customers--if there is an error set this to something elseset @ErrorCode = 0goIn code you would have something like this:cmd.parameters.add("@ErrorCode", SqlDbType.int)cmd.parameters("@ErrorCode").Direction = ParameterDirection.Outputreader =...

Killer Coding Ninja Monkeys DO Exists

So far this has been my favorite intro to a video. But it is true that there are hackers out there and this video shows some of the techniques that people are using (this one is centered around exploiting SQL injection). I found it quite accurate and shows why user input is bad (back to HTML 1.0 for me!)http://www.rockyh.net/AssemblyHijacking/I don't know if I agree with his last point that strong naming the assembly would have fixed this issue. I remembered reading some stuff a long time ago about how to get around this. Granted it adds another layer of security...

Life as a contractor

I have been contracting part time for ages but decided to take the plunge and go full time in feb of 2006. It is an interesting switch and I thought I would share a few points about it that seem to get contractors into trouble:1. As you are your own boss it is easy to slack off (hence me blogging / golfing this afternoon but hey... it's Friday!). I use the time sheet functionality in simply accounting that has a start and stop button to record the hours I actually work. Whenever I slack off I hit stop and when...

Ever wondered what rundll does?

We have all seen rundll sitting in task manager but ever wonder what it did? (besides obviously running a dll)Check out this article