Have you ever came across this error in SQL Server "Conversion failed when converting date and/or time from character string" my query was converting a null value to datetime and throwing that error. To fix it I had to switch from using convert to cast but I want to know why:
If you do the following:
SELECT CONVERT ( datetime, NULL, 101 )
You get no errors and it returns NULL
but when you use CHAR(0) which is equivalent to NULL
SELECT CONVERT ( datetime, CHAR(0), 101 )
You get an error, is there a difference between NULL or CHAR(0) ?
select ascii(Null) B, ascii(char(0))one is null one is not.