Declare @Case1 Int declare @s char(10) Set @Case1=1 set @s=Case @Case1 When 0 Then '为0' When 1 Then '为1' End print @s
uses pubs select title_id, case substring(title_id,2) when 'BU' then 'busiess' when 'MC' then 'modern Cooking' when 'PC' then 'popular computing' end as BookType from titles 试试效果把
declare @s char(10)
Set @Case1=1
set @s=Case @Case1
When 0 Then '为0'
When 1 Then '为1'
End
print @s
select title_id,
case substring(title_id,2)
when 'BU' then 'busiess'
when 'MC' then 'modern Cooking'
when 'PC' then 'popular computing'
end as BookType
from titles
试试效果把