select case when authorid=0 then '游客' else ltrim(authorid) end, case when lastEditorId=0 then '游客' else ltrim(lastEditorId) end from [Fatie]
select case when authorId=0 and lastEditorId=0 then '游客' else authorName end from Fatie
select authorId=case when authorId=0 then N'游客' else authorId end ,lastEditorId =case when lastEditorId =0 then N'游客' else lastEditorId end from fatie
这个方法可以,我想问下为什么加了ltrim就不会报错了我之前是这么写的 select case when author=0 then '游客' else author end from TLiuYanFaTie可是老报错: 服务器: 消息 8114,级别 16,状态 5,行 1 将数据类型 varchar 转换为 bigint 时出错。
select case when authorId=0 and lastEditorId=0 then '游客' else authorName end from Fatie
case when lastEditorId=0 then '游客' else ltrim(lastEditorId) end
from [Fatie]
from fatie
这个方法可以,我想问下为什么加了ltrim就不会报错了我之前是这么写的
select
case when author=0 then '游客' else author end
from TLiuYanFaTie可是老报错:
服务器: 消息 8114,级别 16,状态 5,行 1
将数据类型 varchar 转换为 bigint 时出错。
http://topic.csdn.net/u/20081022/16/e922d867-d42d-4ee2-bb3f-6c3c8559d225.html