在sqlServer中,用isnull判断空值时要注意一点:isnull()会把返回值强制转换成第一个类型。 如: declare @test1 varchar(2), @test2 varchar(100) set @test2='test isnull()' select isnull(@test1, @test2) select coalesce(@test1, @test2) 运行结果 te test isnull() 所以遇到字符串长度不一致时,最好用coalesce去判断空值。 参考资料:http://archive.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=ISNULL_COALESCE&referringTitle=Home#ISNULL_Definition |
|