damar123:
there is at least ONE BIG difference when using ISNULL and COALESCE:
<snip>
Thanks, that's useful to know.
I expanded your example a bit to test what's going on, and if you run this...
DECLARE @tinyint tinyint
SELECT
ISNULL(@tinyint, 1) AS col0,
CONVERT(tinyint,ISNULL(@tinyint, 1)) AS col1,
COALESCE (@tinyint, 1) AS col2,
COALESCE (@tinyint, 5000000000000) AS col3,
COALESCE (@tinyint, 500000000000000000000000) AS col4
INTO TESTTABLE
you end up with this table def...
CREATE TABLE [dbo].[TESTTABLE](
[col0] [tinyint] NOT NULL,
[col1] [tinyint] NULL,
[col2] [int] NULL,
[col3] [numeric](13, 0) NULL,
[col4] [numeric](24, 0) NULL
) ON [PRIMARY]
the differences in field defs and the NULL/NOT NULL is quite interesting.