Hi all, played for a while with Hugo's example and ... look what I found
First, I have tested and it errors on 2008, works on 2005.
So, the following applies to SQL Server 2008. Here is the script, note the results from selects in the end of the script:
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'Weird') BEGIN
ALTER DATABASE [Weird] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DROP DATABASE [Weird]
CREATE DATABASE [Weird]
-- set compatibility level
ALTER DATABASE [Weird] SET COMPATIBILITY_LEVEL = 90
ALTER DATABASE [Weird] SET RECOVERY SIMPLE
SELECT ROUND(789.98,-3) AS WeirdCol
-- 1 ok
SELECT COUNT(*) FROM WeirdTable
-- 2 doesn't work
SELECT WeirdCol FROM WeirdTable
--3 explicit cast works !!!
SELECT CAST(WeirdCol as decimal(6,2)) FROM WeirdTable
Now you have to admit that this is realy weird
PS: If I had a blog this would probably be worth blogging about. Hugo?