以下的语句的书写,总报错有问题,请问应怎么改进下面的语句。(因存储过程执行结果字段不固定,故无法先建临时表再插入)
select * into #t from Openrowset('sqloledb','Trusted_connection=yes','exec OTERP_JT.dbo.AccAssetsDisPosal @code,@tmonth')
select * into #t from Openrowset('sqloledb','Trusted_connection=yes','exec OTERP_JT.dbo.AccAssetsDisPosal @code,@tmonth')
Openrowset( 'sqloledb ', 'Trusted_connection=yes ', 'exec OTERP_JT.dbo.AccAssetsDisPosal '+@code+','+@tmonth +')
declare @code varchar(20),@tmonth varchar(10)
set @code=??
set @tmonth=??
exec
(
'select * into #t from Openrowset(''sqloledb'',''Trusted_connection=yes'',''exec OTERP_JT.dbo.AccAssetsDisPosal '''''+@code+''''','''''+@tmonth+''''''')'
--其它处理逻辑
)
“Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS
options to be set for the connection. This ensures consistent query semantics.
Enable these options and then reissue your query.”
as
set nocount on
declare @code varchar(20),@tmonth varchar(10)
set @code='A6537'
set @tmonth=10
exec
(
'select * into #t from Openrowset(''sqloledb'',''Trusted_connection=yes'',''exec ZWQ_RR.dbo.AccAssetsDisPosal '''''+@code+''''','''''+@tmonth+''''''')')
select * from #t
drop table #t然后我在查询分析器中执行这个存储过程:
exec TestCom
报错:
“Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS
options to be set for the connection. This ensures consistent query semantics.
Enable these options and then reissue your query.”