Tuesday, May 8, 2007

Unpaids, SQL bug and Wakelin

So I finally managed to run the month-end unpaids import that took me (only) 10 hours to rewrite. That goodness for that. Found something interesting while doing it though with SQL 2005. No sure if this behaviour is by design (in other words put there to piss me off) or is it a bug.



DECLARE @vchString1 varchar(2),
@vchString2 varchar(10),
@iErrorval int

SELECT @vchString1 = 'abc'

SELECT @vchString1

SELECT @vchString2 = 'abcdefghij'

SELECT @vchString1 = @vchString2

SELECT @vchString1

CREATE TABLE #Test(vchString1 varchar(2),vchString2 varchar(10))
INSERT INTO #TestVALUES(@vchString2, @vchString2)

SELECT @@ERROR as [ErrorCode]

SELECT @@ERROR as [ErrorCode]

DROP TABLE #Test



Just so that you know what you are looking for - SQL truncates varchar's with out warning, but will warn you if you insert it into a table. Then I found out that the first time you reference @@ERROR it returns that code but the second...well you try it and see what happens *ARGH*!

My cousin James (Wakelin) visited me last night. Much chatching up and whiskey drinking ensued. He has recommended a book to all the open-minded people out there: The God Delusion. Haven't read it yet as I have too many others on my 'to be read' pile.

I think I shall start with either: A short history of nearly everything or By the River Piedra I sat Down and Wept.

No comments: