我的动态语句怎么才能运行?
问题行要怎么写才能运行?
我试过下面几种写法,都不行:
if exists (@str1)
if exists (exec @str1)
if exists (exec sp_executesql @str1)
declare @fisyear varchar(4)
declare @str1 varchar(300)
declare @t table (msg nvarchar(100))
set @fisyear='2003'
set @str1 = 'select distinct ts_office from cpm_timesheet where ts_fisyear='''+@fisyear+''' and ts_office not in (select distinct mf_office from cpm_MF where mf_fisyear='''+@fisyear+''')'
select @str1
if exists (@str1) <--问题行
begin
declare @err_mf cursor for @str1
open @err_mf
fetch next from @err_mf into @err_office
while @@fetch_status=0
begin
insert into @t values (@err_office+N'办公室 '+@fisyear+N'财政年度 没有办公室倍率')
fetch next from @err_mf into @err_office
end
end
select * from @t
我试过下面几种写法,都不行:
if exists (@str1)
if exists (exec @str1)
if exists (exec sp_executesql @str1)
declare @fisyear varchar(4)
declare @str1 varchar(300)
declare @t table (msg nvarchar(100))
set @fisyear='2003'
set @str1 = 'select distinct ts_office from cpm_timesheet where ts_fisyear='''+@fisyear+''' and ts_office not in (select distinct mf_office from cpm_MF where mf_fisyear='''+@fisyear+''')'
select @str1
if exists (@str1) <--问题行
begin
declare @err_mf cursor for @str1
open @err_mf
fetch next from @err_mf into @err_office
while @@fetch_status=0
begin
insert into @t values (@err_office+N'办公室 '+@fisyear+N'财政年度 没有办公室倍率')
fetch next from @err_mf into @err_office
end
end
select * from @t
...全文
相关推荐
SAP ABAP 动态语句详解
详细介绍ABAP里面动态语句的写法 FIELD-SYMBOLS 申明的类型详解
动态拼接sql语句.rar
动态拼接sql语句.rar 动态拼接sql语句.rar 动态拼接sql语句.rar 动态拼接sql语句.rar 动态拼接sql语句.rar 动态拼接sql语句.rar
浅析PowerBuilder下动态SQL语句.pdf
浅析PowerBuilder下动态SQL语句.pdf
学习SQL应知道的动态SQL语句基本语法
学习SQL应知道的动态SQL语句基本语法
JDBC的动态SQL语句在浏览器_服务器模式中的应用.pdf
JDBC的动态SQL语句在浏览器_服务器模式中的应用.pdf


疑难问题
