Friday, June 17, 2011

Stupid Error Messages

Have you ever seen an error message like this one?

Invalid phone number (212) 555-1284 - not numeric
Maybe this one?
Invalid phone number 2125551284 - format not (999) 999-999
Both messages are stupid, stupid, stupid... that's three "stupids" out of a maximum possible score of 5. Modern systems should be able to deal with human-readable input formats like credit card numbers with or without the dashes.
Invalid credit card number 4533-3048-3842-9544 - not numeric

Today's Stupid Error Message



CREATE TABLE t (
pkey UNIQUEIDENTIFIER NOT NULL PRIMARY KEY );

INSERT t VALUES ( '4b67abbe3c9246f883db0ab2d2b78f8b' );
GO

Msg 8169, Level 16, State 2, Server ENVY, Line 4
Conversion failed when converting from a character string to uniqueidentifier.

You need the dashes for that when using SQL Server 2008:

INSERT t VALUES ( '4b67abbe-3c92-46f8-83db-0ab2d2b78f8b' );
GO

(1 row affected)

I suppose we should be grateful it accepts lower case.

For the record, SQL Anywhere has no such difficulty:

CREATE TABLE t (
pkey UNIQUEIDENTIFIER NOT NULL PRIMARY KEY );

INSERT t VALUES ( '4b67abbe3c9246f883db0ab2d2b78f8b' );

Execution time: 0.43 seconds
1 row(s) inserted

As they say, Watcom does things they way they should be done.


1 comment:

jpo said...

Why did it take 0.43 seconds to insert one row? Is there something special about uniqueidentifier that makes this slow?