Data type precedence while using UNION statement differs in behavior between SQL Server 2000 and SQL Server 2005

by Anith on May 27, 2009

  It originally seemed to be a quite complex problem, involving an update trigger that was failing in SQL Server 2005, but had never failed in SQL Server 2000, giving a message like "Syntax error converting the varchar value ‘whatever’ to a column of data type INT " when the calling code was doing something simple like "UPDATE TBL SET SOMECOL=’NEWVALUE’ WHERE PK = 123" <Trigger Code Snippet> INSERT INTO DBO.AUDIT_TABLE ( … COLNAME, OLDVALUE, NEWVALUE ) SELECT … ‘SOMECOL’, D.SOMECOL,I.SOMECOL FROM INSERTED I JOIN DELETED D ON I._PK = D._PK WHERE …

The rest is here: 
Data type precedence while using UNION statement differs in behavior between SQL Server 2000 and SQL Server 2005

Leave your comment

Required.

Required. Not published.

If you have one.