in reply to Error in my MS SQL script

Why do you say AutoCommit => 0, but don't commit later on? This should explain it, if the code shown contains all of the relevant logic and statements (does it?).

Considering the first two answers, I prefer Corion's answer with the extra background over this one :)
(and I really should start to remember checking the thread between preview and node create).

Update: I was initially a bit confused by the upvotes. After some thinking, I'd rather take & accept it as my fellow monks' congrats to overcoming the initial monk's level-rushing xp-whore-phase :).