日期:2014-05-17 浏览次数:20455 次
declare @Sql varchar(1000) declare @ACCOUNT varchar(50)='-1' --@ACCOUNT 为 testName 时也需要符合 Set @Sql ='select * from T_ORDER where ('+CASE @ACCOUNT WHEN '-1' THEN '1=1' ELSE 'ACCOUNT = '''+CAST(@ACCOUNT AS varchar(50)) END+''') ' select @Sql
ACCOUNT = '''+CAST(@ACCOUNT AS varchar(50)) END+'''
ACCOUNT = '+CAST(@ACCOUNT AS varchar(50)) END+'
declare @Sql varchar(1000) declare @ACCOUNT varchar(50)='-1' --@ACCOUNT 为 testName 时也需要符合 Set @Sql ='select * from T_ORDER where ('+CASE @ACCOUNT WHEN '-1' THEN '''' ELSE 'ACCOUNT = '''+CAST(@ACCOUNT AS varchar(50)) END+''') ' select @Sql
------解决方案--------------------
declare @Sql varchar(1000) declare @ACCOUNT varchar(50) --@ACCOUNT 为 testName 时也需要符合 set @ACCOUNT='-1' Set @Sql ='select * from T_ORDER where ('+CASE @ACCOUNT WHEN '-1' THEN '1=1' ELSE 'ACCOUNT = ''' +CAST(@ACCOUNT AS varchar(50)) END+') ' select @Sql
------解决方案--------------------
declare @Sql varchar(1000)
declare @ACCOUNT varchar(50)='-1' --@ACCOUNT 为 testName 时也需要符合
Set @Sql ='select * from T_ORDER where ('+CASE @ACCOUNT WHEN '-1' THEN ' 1=1 ' ELSE ' ACCOUNT = '''+CAST(@ACCOUNT AS varchar(50))+'''' END +')'
select @Sql