我有这个sql,
IF(@ID = '') BEGIN SET @ID = NULL; END IF(@Name = '') BEGIN SET @Name = NULL; END IF(@PhoneNumber = '') BEGIN SET @PhoneNumber = NULL; END IF(@Price = '') BEGIN SET @Price = NULL; END IF(@NewPrice = '') BEGIN SET @NewPrice = NULL; END IF(@ModelNumber = '') BEGIN SET @ModelNumber = NULL; END IF(@SKU = '') BEGIN SET @SKU = NULL; END
我正在寻找IsEmpty函数,如ISNULL.所以我可以,
ISEMPTY(@SKU,NULL)
这在sql中是否可行.
解决方法
尝试
NULLIF如下
NULLIF(@SKU,'')