Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.

I just re-factored an SQL Server stored procedure to use sp_executesql. Lots of cut and paste. It looked almost identical to a sibling stored procedure, at least in terms of local variable declarations and parameter list declaration. So why, where the sibling stored procedure returned results, did this stored procedure generate this error message?

Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'

Richard Dudley had the answer. I had inadvertently declared my @queryStr variable as varchar instead of nvarchar.

Implementing file download links

It's amazing how many basic web developer techniques I still don't know.

I want to provide a file download link. But the URL is not a static path like

Instead it points to an ASP.NET or PHP page, e.g.

And it returns dynamically-generated, plain-text, comma-separated-value content.

How do I convince Safari to download the file, rather than simply loading it in the browser window? How do I convince Firefox that the downloaded content is really text/csv and not a file of type php or aspx?

The answer, courtesy of the online PHP manual: use a content-disposition header.

To find the details, go to the PHP manual page and search for "Content-Disposition".

Safari / WebKit Feature Request

Google has this nice feature: select "some text" in a web page, right-click, and you see a menu item:

Search current search engine for "some text"
When you select the menu item, Firefox performs the search and presents the results in a new tab.

This behavior is really useful. For example, when you're reading a forum post in which someone cites an API or software product you've never heard of, you can go off and learn more about the citation without losing your place in the forum.

WebKit (and Safari3?) have a similar menu item. Of course, unless you've installed some 3rd-party extensions the search engine is always Google. But the really unfortunate thing is that the search results replace the current page.

Maybe there's a magic key combination which lets you override this behavior, but I haven't found it yet. It sure would be nice if Safari implemented this feature in the same way as Firefox.

Where's the Clipboard Viewer in Windows XP?

I couldn't find a clipboard viewer anywhere in my XP Start Menu hierarchy. Once again, the web provides. From Where's the Clipboard Viewer in Windows XP?

  1. Click the Start menu button and open My Computer.
  2. Open your C drive. (It's listed in the Hard Disk Drives section.)
  3. Double-click on the Windows folder. (You might have to tell it to let you see what's inside.)
  4. Double-click on the System32 folder. (Again, you might have to tell it to let you see what's inside.)
  5. Scroll down the page until you locate a file named Clipbrd.
  6. Drag and drop the Clipbrd file onto your Start button.

Shrinking your Visual Web Developer project databases

It's annoying that my web app's SQL Server 2005 database file is less than one megabyte in size; whereas the internal application database created by Visual Web Developer, with which I've never mucked directly, is over 10MB.

Of couse the blogosphere has known about this problem much longer than I have. And here's a handy solution:

Shut-Up and Smile : ASP.NET Membership Database Squish

This script does the equivalent of the SQL Server Management Studio's "Tasks->Shrink" menu item. I have a hard time using that menu item on my application's database file, perhaps because of file ownership issues. Whatever: this script smooshed things right down to size.

Modifying a wrong commit message in a svn/trac combo

Sometimes I screw up a commit comment in subversion, and need to fix it. I can never remember how to do so. 'svnadmin setlog' seems obviously the way to go, but when I try to use that command I get an error message:

svnadmin: Repository has not been enabled to accept revision propchanges;
ask the administrator to create a pre-revprop-change hook

Here's the right way to do it, including extra steps which make Trac aware of the change:
modifying a wrong commit message in a svn/trac combo

The need for the trac-sync step implies that trac uses a subversion commit hook to record the details of each subversion commit.

SQL Server: Avoiding multiple record sets

I have a stored procedure which needs to execute other stored procedures in order to generate its results. Unfortunately, those nested stored procedures can perform SELECTs. The end result is that, instead of returning one record set, my stored procedure may return multiple record sets.

How to prevent this? According to

After the BEGIN command, we SET NOCOUNT ON -- this prevents interim statements from being returned as recordsets.

Does NOCOUNT really affect whether or not multiple record sets are returned? Not when you're dealing with nested execution of stored procedures...

The only solution I can find is to create a temporary table, in the calling stored procedure, and to dump the results of the called stored procedure into that temporary table, then to delete it.

CREATE TABLE [#unused] (foo REAL, bar REAL);
INSERT INTO [#unused] EXECUTE my_nested_sp @arg1, @arg2;
DROP TABLE [#unused];

MarsEdit 1.2: Growl, Picasa and Vox!


MarsEdit 1.2: Growl, Picasa and Vox!:

MarsEdit 1.2 is now available for download (or just ‘Check for Updates’ from the app). This is a free update for all registered MarsEdit users.Three relatively big changes in this release: [...]

Picasa image uploads for This is pretty transparent. Just select your Blogger blog as the upload target from Images & Files, and MarsEdit will pop the images into a MarsEdit album in your Picasa Web Albums account. Note that Picasa only accepts JPG format images for upload.

Woohoo! I've been wanting this for a long time. And it looks like it works just fine!

Thank you, Daniel Jalkut.


MySQL has handy syntax which lets you look for a record by primary key and, if it exists, update its fields; otherwise insert a new record.

I wish something similar existed for SQL Server. If it does, I can't find it. But there is another way to achieve a similar effect, without too much typing:

DELETE FROM my_table WHERE prim_key = @prim_key_val;
INSERT INTO my_table (prim_key, other_field)
VALUES (@prim_key_val, @other_field_val);

I'm probably missing something; haven't thought this through very carefully.