select *  from planadmin where file_ = ']01号' or file_ = '1336号' 这条语句还能合并吗??我想在set @s='select * into t from planadmin where '+substring(@t,5,4000)中加入上面语句的条件file_ = ']01号' or file_ = '1336号' ,应该怎么加??

解决方案 »

  1.   

    declare @s nvarchar(4000),@t nvarchar(4000)set @t=case when @pro_no<>'' then ' and pro_id=@pro_no' else '' end --项目名称
      +case when @pro_name<>'' then ' and pro_name like ''%'+@pro_name+'%''' else '' end --项目名称模糊查询
      +case when @file_<>'' then ' and file_ like''%'+@file_+'%'''+'{escape ''/''}' else '' end --文件号模糊查询
      +case when @city_name<>'请选择' then ' and city_name=@city_name' else '' end --市名称
      +case when @county_name<>'请选择' then ' and county_name=@county_name' else '' end --县名称
    if @t<>'' --为空? --执行sql语句,从表中找出几个字段
    begin
       set @s='select * into t from planadmin where '+substring(@t,5,4000)我想给'select * into t from planadmin where '+substring(@t,5,4000)再加一个条件,条件为file_ = ']01号' or file_ = '1336号' ,应该怎么加?? 
      

  2.   

    set @s='select * into t from planadmin where '+substring(@t,5,4000)+' and (file_ = '']01号'' or file_ = ''1336号'')' 
      

  3.   

    set @s='select * into t from planadmin where '+substring(@t,5,4000)+' and (file_ = '']01号'' or file_ = ''1336号'')'