My field in my SKU table
(BI.dbo.SKU.phl5)
is varchar(15)
However below code returns just 3 characters 'Unc'
for the null fields in my table while it should return 'Uncategorized'
. How to solve that?
ISNULL(SUBSTRING(BI.dbo.SKU.phl5,0,3),'Uncategorized') AS phl1
ISNULL
takes two parameters, and returns the first, unless it isNULL
, in which case it returns the second. So obviously, ifphl5
contains "Uncategorized", you'll return "Unc" since ISNULL will return the result of the substring. Please explain the logic behind what you want (not the code logic, the "thinking" logic, what you want and why) – Lasse V. Karlsen Jun 5 '13 at 8:29