日期:2014-05-18 浏览次数:20593 次
Select * From 表A Where .....
Select ItemName From 表B Where plan_id=@plan_id
Select * From 表A
Select * From 表A Where ID IN (Select ItemName From 表B Where plan_id=@plan_id )
Select ItemName From 表B Where plan_id=@plan_id if (@@rowcount = 1) and (ItemName = 'xx') Select * From 表A else Select * From 表A Where ID IN (Select ItemName From 表B Where plan_id=@plan_id )
------解决方案--------------------
drop table tb create table tb (id int,AN varchar(8000),CN varchar(8000)) insert tb select 1,'a','121' insert tb select 2,'','123' insert tb select 3,'s','123' create table tb (id int,AN varchar(8000),CN varchar(8000)) insert tb select 1,'a','121' insert tb select 2,'','123' if(exists(select 1 from tb where an != '' and cn='123') ) exec('select * from tb where an !='''' and cn =''123''') else exec('select * from tb where an ='''' and cn =''123''')
------解决方案--------------------
使用
if else
declare @ID int set @ID = 1 if @ID = 1 begin select COunt(*) from sysobjects set @ID = 2 end else select count(*) from sysfiles
------解决方案--------------------
if @@rowcount = 1 and Case_ItemID = 'All'
????????????????////////
郁闷,怎么能这样用的
----------------
declare @DisplayChar int declare @Plan_ID int declare @Case_ItemID varchar(20) set @Plan_ID ='1006' Select @Case_ItemID = Ltrim(Case_ItemID) From Report_Planparameter2 Where Plan_Id =@Plan_ID and Case_name = 'account' if @@rowcount = 1 and @Case_ItemID = 'All' select @DisplayChar = '' else select @DisplayChar = '1'