http://expert.csdn.net/Expert/topic/2364/2364046.xml?temp=.829693
[交流]动态SQL语句
[交流]动态SQL语句
解决方案 »
- SQL Server evaluation period has expired
- NND,四核的CPU,各个都占用90%,SQL占用90%
- ASP+MSSQL 读取数据的简单问题
- 限定小数位数
- 小弟有个右连接的存储过程,不知道哪里错了,请大侠帮忙看一下
- 求取得时间字段的年份列表的方法,
- 求助一个判断表里面为空值数量查询的问题
- IronPromises(铁诺)请进
- 怎样用VB将SQL Server中的数据库设为单用户模式?
- 现有三张表: dic_gzxm(dic_code与表qqkjbz的gzxm相关连) 、qqkjbz、dic_kfbz(dic_code与表qqkjbz的KFBZ相关连),我想把其他两张表中的一部
- 怎么处理插入多条数据时的自动编码呀?
- 不打开数据表能不能判断一个数据表是否为空?
--->
declare @str nvarchar(4000)
set @str = 'select @ifwj=count(*) from '+@bblb +'
where xmjlb='+cast(@xmjlb as varchar(10))+' and xmmc='+cast(@xmmc as varchar(10))
+'and year(a.insert_time)='
+cast(@nd as char(4))+' and month(a.insert_time)='+ cast(@yf as char(2))
exec sp_executesql @str,N'@ifwj int output',@ifwj output
AS
begin
set nocount on
set @reid=0
declare @ifwj int
set @ifwj=-1
select @ifwj=是否完结 from 公文 where 流程步ID=@mod and 项目经理部=@xmjlb and 建设项目名称=@xmmc and 报表年=@nd and 报表月=@yf and 类别=1 and 报表类型=@bblb
if(@ifwj<>-1)
begin
if(@ifwj=0)
set @reid=1
return
if(@ifwj=1)
set @reid=2
return
end
declare @a nvarchar(4000)
set @a='select @ifwj=count(*) from '+@bblb+' where xmjlb='+cast(@xmjlb as varchar(10))+' and xmmc='+cast(@xmmc as varchar(10))+' and year(a.insert_time)='+cast(@nd as varchar(10))+' and month(a.insert_time)='+cast(@yf as varchar(10))
exec sp_executesql @a,N'@ifwj int output',@ifwj output
if(@ifwj=0)
begin
set @reid=3
return
end
end
exec('select' + @ifwj + '=count(*) from' + @bblb + 'where xmjlb=' + @xmjlb + 'and xmmc=' + @xmmc + 'and year(a.insert_time)=' + @nd + ' and month(a.insert_time)=' + @yf)
AS
begin
set nocount on
set @reid=0
declare @ifwj int
set @ifwj=-1
select @ifwj=是否完结 from 公文 where 流程步ID=@mod and 项目经理部=@xmjlb and 建设项目名称=@xmmc and 报表年=@nd and 报表月=@yf and 类别=1 and 报表类型=@bblb
if(@ifwj<>-1)
begin
if(@ifwj=0)
set @reid=1
return
if(@ifwj=1)
set @reid=2
return
end
declare @a nvarchar(4000)
set @a='select @ifwj=count(*) from '+@bblb+' where xmjlb='+cast(@xmjlb as varchar(10))+' and xmmc='+cast(@xmmc as varchar(10))+' and year(a.insert_time)='+cast(@nd as varchar(10))+' and month(a.insert_time)='+cast(@yf as varchar(10))
exec sp_executesql @a,N'@ifwj int output',@ifwj output
if(@ifwj=0)
begin
set @reid=3
return
end
end