declare @ExecSql varchar(500)
set @ExecSql='exec sp_addlinkedserver ''ora'',''oracle'',''msdaora'',''stat'''
exec(@ExecSql)
set @ExecSql='exec sp_addlinkedsrvlogin ''ora'',''false'',''sa'',''bss'',''bss'''
exec(@ExecSql)
IF EXISTS (SELECT * FROM sysobjects WHERE name='ymtx' and type='u')
DROP TABLE [dbo].[YMTX]
IF EXISTS (SELECT * FROM sysobjects WHERE name='product_hm' and type='u')
DROP TABLE [dbo].[product_hm]
IF EXISTS (SELECT * FROM sysobjects WHERE name='product_hm4' and type='u')
DROP TABLE [dbo].[product_hm4]
IF EXISTS (SELECT * FROM sysobjects WHERE name='hmyys' and type='u')
DROP TABLE [dbo].[hmyys]
set @ExecSql='select * into bss.dbo.YMTX from ora..BSS.YMTX'
exec(@ExecSql)
set @ExecSql='select * into bss.dbo.product_hm from ora..BSS.PRODUCT_HM'
exec(@ExecSql)
set @ExecSql='select * into bss.dbo.product_hm4 from ora..BSS.PRODUCT_HM4'
exec(@ExecSql)
set @ExecSql='select * into bss.dbo.hmyys from ora..BSS.HM_YYS'
exec(@ExecSql)
set @ExecSql='create index access_number on bss.dbo.product_hm4 (access_number)'
exec(@ExecSql)
set @ExecSql='exec sp_dropserver ''ora'',''droplogins'''
exec(@ExecSql)
语句在查询分析器中可以直接运行,将语句放入SQL SERVER代理作业中报错
执行用户: NT AUTHORITY\SYSTEM。OLE DB 提供程序 'msdaora' 报错。验证失败。 [SQLSTATE 42000](错误 7399) [SQLSTATE 01000](错误 7312) OLE DB 错误跟踪[OLE/DB Provider 'msdaora' IDBInitialize::Initialize returned 0x80040e4d: 验证失败。]。 [SQLSTATE 01000](错误 7300). 步骤失败。
如何解决这个问题
------解决方案--------------------
代理中的sQl server 连接的问题,不能用windows身份验证,得用sysadmin登陆,
具体设置方法如下:在企业管理器中->管理->SQL Server 代理->右键菜单"属性"->分页选项卡上选"连接"->"使用SQL