This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / SQL Server2005, A是text field. 要求A 不能是空值(如果A是space也不行, 比如A=' '), 我用((RTRIM(LTRIM(A + '')) <>'' and (A is not null)), 一运行就出错,The data types text and varchar are incompatible in the add operator. 请问这个statement应该怎么写? 谢谢!
-zxcvb(朝天椒);
2006-3-9
{104}
(#2829582@0)
-
cast
-chenjichang(龙丘居士);
2006-3-9
(#2829635@0)
-
Thanks a lot. It works!
-zxcvb(朝天椒);
2006-3-9
(#2829650@0)
-
两个condition换个位. null <> '' is not valid.
-qq00(Daisy);
2006-3-9
(#2829652@0)
-
没看懂, 怎么换?
-zxcvb(朝天椒);
2006-3-9
(#2829677@0)
-
:-) you have to check if A is null or not first, then to check if A is empty or not. otherwise, if A is null, you check its content first, then an exception would thrown out.
-warmbedtonight(来吧...);
2006-3-9
(#2829770@0)
-
明白了,谢谢
-zxcvb(朝天椒);
2006-3-9
(#2829778@0)
-
the condition should be set in this order:1. filter out A is not NULL: Not A is NULL
2. length is greater than zero: LEN(LTRIM(A)) > 0
I donot think we need to use LTRIM(RTRIM(A)), coz if A is a string with space, only LTRIM or RTRIM is enough.
-warmbedtonight(来吧...);
2006-3-9
{206}
(#2829758@0)
-
right. 我这是用左手挠右边耳朵, 再用右手挠左边耳朵 :-) 谢谢
-zxcvb(朝天椒);
2006-3-9
(#2829775@0)