日期:2014-05-19  浏览次数:20339 次

Case的困惑??
Case   @sUserType
When   'gagant '   then   print   'a '
Else   print   'b '
End

------解决方案--------------------
Declare @sql varchar(8000)
Select @sql=Case @sUserType
when 'gagant ' then 'insert into gagant... '
when 'agant ' then 'insert into agant... '
else 'insert into user... ' end

exec(@sql)
------解决方案--------------------
晕,
insert into agant (col)
select
(case @sUserType when 'gagant ' then ...
case @sUserType when 'agant ' then ...
else ...
end) from tb where ....