SQL Server 2008 中是否有类似下面的方法?
可以根据条件指定外部应用(连接)表吗?
declare @bGetExtendedInfo bit
set @bGetExtendedInfo = 1
declare @param nvarchar(24)
set @param = 'CO-02-BBB'
select t1.*, t2.ID
from t1
outer apply (
case when @bGetExtendedInfo= 0
then (select 0) as ID /* dummy value */
/*really expensive query trying to avoid when extended info is not needed*/
else (select top 1 ID from tbl1 where tbl1.code = @param)
end
) t2