In my database, I have several computed columns to provide referential integrity constraints. I use calculated columns, not default columns, because LINQ2SQL, which I use, does not understand the default values ββfrom the database.
My attempt to use
CAST('C' as CHAR(1))
which automatically converts to
(CONVERT([char](1),'C',0))
by SSMS. However, this results in a CHAR (1) column type with NULL.
If I just use 'C' or ISNULL(NULL,'C') (which results in a type other than NULL), the column is selected as VARCHAR (?). And, if I combine the two to use ISNULL(NULL,CONVERT([char](1),'C',0)) , I will return to the NULL-capable CHAR (1).
There are two reasons for this:
Update:
This works for me with ISNULL(CONVERT([char](1),'C',0),0) , but I'm not sure why. Anyway, it looks like ISNULL(..,0) will be of un-unifiy type next.
I would be more than happy for the answer with a good explanation.
user166390
source share