Author Archive

Find text inside stored procedures

The following snippet allows you to find all stored procedures containing a specific word or words. I found it to be very helpful to find all references to a table I needed to remove from my database. I order not to break functionality I scanned all procs for references and changed or removed them. Here [...]

More »

Find most expensive queries in Microsoft SQL server

A colleague of mine found this little gem of a query (sorry, don’t know the original author). It finds the 20 most expensive queries executed on a SQL server instance, sorted by execution time. CPU load is also returned by the query. Here it is: SELECT TOP 20 qs.sql_handle, qs.execution_count, qs.total_worker_time AS Total_CPU, total_CPU_inSeconds = –Converted from microseconds qs.total_worker_time/1000000, average_CPU_inSeconds = –Converted from microseconds (qs.total_worker_time/1000000)/ qs.execution_count, [...]

More »

Some nice programming quotes I came across…

Walking on water and developing software from a specification are easy if both are frozen. – Edward V. Berard Hofstadter’s Law: It always takes longer than you expect, even when you take into account Hofstadter’s Law. Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code [...]

More »

10 Free Tools to Load/Stress Test Your Web Applications

Follow the link… http://www.devcurry.com/2010/07/10-free-tools-to-loadstress-test-your.html

More »

Script failed for Trigger ‘Trigger-name’. (Microsoft.SqlServer.Smo))

It’s a documented bug in SQL server that causes above error message. The error is triggered by nested comment blocks, like this example: /* some comments /* nested comments*/ some more comments */ All very well, it’s a documented bug so it shouldn’t be a problem. Microsoft’s solution is plain and effective: don’t use nested comment [...]

More »

How to display table sizes in SQL server

There are a few ways to retrieve the table sizes (both row count and size in bytes) in SQL server. The simplest is the sp_spaceused stored procedure which takes a table name as argument: EXEC sp_spaceused ‘table_name’ This is all fine, but what if you want to display info about a dozen or more tables? [...]

More »

Windows 7 – Explorer.exe server execution failed

On my company laptop I have a network drive attached which is not always available. Recently I got annoyed about files not always being there so I decided to disconnect the company drive all together. After restarting I then got EXPLORE.EXE server execution failed and the Windows Explorer no longer started. Turns out I had [...]

More »

Make a .NET web service accept GET requests

The usual way to call web service is by using POST requests. But sometimes GET requests are required. To make .NET web services accept their parameters from GET requests, add a ScriptMethod attribute to your web service routine. First add some libraries: C# Using System.Web.Services; Using System.Web.Services.Protocols; Using System.Web.Script.Services; Visual Basic Imports System.Web.Services Imports System.Web.Services.Protocols [...]

More »

How to rename a column in a MS-SQL database?

Easy peasy, use the sp_rename stored procedure: EXEC sp_rename ‘TABLENAME.OLD_COLUMNNAME’, ‘NEW_COLUMNAME’, ‘COLUMN’;

More »

CakePHP: catching errors in Model->query()

In my recent CakePHP application I use some custom SQL queries that I fire at the database using the $model->query($sql) syntax. Works great, until you have an error in your $sql. I tried the obvious error handling with try … catch: try {   $this->Model->query(’INSERT INTO model WHERE id=invalid’); } catch (exception $ex) {   [...]

More »

How to: Check if a Microsoft SQL-server database exists?

Here’s an easy, single line statement to check if a database exists in the current SQL-server instance: IF db_id(’db_name’) IS NOT NULL

More »

First post from iPhone

Hi all, this is my first post from my iPhone. I’m using the WordPress 2.0 iPhone app (make sure XML-RPC is enabled in your WordPress back-end). Even adding images from the iPhone Camera Roll is easy peasy.

More »

Compute hash of a file

Computing the hash value of a file is quite strait forward. I use the routine below. It opens the file, specifies the hash-algorithm to use and returns the hash of the file. If you rather use MD5 hashes, just change hashAlgorithm into MD5CryptoServiceProvider. Public Function ComputeFileHash(ByVal fileName As String) As String   Dim hashAlgorithm As [...]

More »

Icon Finder, the Google for icons

Here’s a very useful tool: http://www.iconfinder.net/ It allows you to search for icon, and it returns a lot of high quality images. Recommended!

More »

How to: Get the name of the running SQL-server instance

Here’s a script to retrieve the name of the currently running SQL Server instance: SELECT @@SERVERNAME AS ‘ServerName’ Resultset: ServerName ————————— DEV-SQL (1 row(s) affected)

More »