日期:2014-05-18 浏览次数:20499 次
set @wheretrue ='select DEPT_CODE from T_DEPT where BRANCH_CODE='''+@city+''''
------解决方案--------------------
if(@city='') set @wheretrue='select DEPT_CODE from T_USERDEPT where USER_NO='''+@user+'''' else set @wheretrue ='select DEPT_CODE from T_DEPT where BRANCH_CODE='''+@city+''''
------解决方案--------------------
ALTER PROCEDURE [dbo].[proc_business] @user varchar(20), @city varchar(20), AS BEGIN declare @wheretrue varchar(100) if(@city='') set @wheretrue='select DEPT_CODE from T_USERDEPT where USER_NO='''+ltrim(@user)+'''' else set @wheretrue ='select DEPT_CODE from T_DEPT where BRANCH_CODE='''+@city+'''' select * from P_BUSINESS_LIST where DEPT_CODE in (' +ltrim(@wheretrue)+ ') END
------解决方案--------------------
ALTER PROCEDURE [dbo].[proc_business] @user varchar(20), @city varchar(20), AS BEGIN declare @wheretrue varchar(100) if(@city='') set @wheretrue='select DEPT_CODE from T_USERDEPT where USER_NO='''+ltrim(@user)+'''' else set @wheretrue ='select DEPT_CODE from T_DEPT where BRANCH_CODE='''+@city+'''' exec('select * from P_BUSINESS_LIST where DEPT_CODE in (' +ltrim(@wheretrue)+ ')') END
------解决方案--------------------
ALTER PROCEDURE [dbo].[proc_business] ( @user varchar(20), @city varchar(20) ) AS BEGIN declare @wheretrue varchar(100) if(@city='') set @wheretrue='select DEPT_CODE from T_USERDEPT where USER_NO='''+ltrim(@user)+'''' else set @wheretrue ='select DEPT_CODE from T_DEPT where BRANCH_CODE='''+@city+'''' exec('select * from P_BUSINESS_LIST where DEPT_CODE in (' +@wheretrue+ ')') END
------解决方案--------------------
双引号外面套单引号 '"+xxxxx+"'