Ad hoc access to OLE DB provider 'MSDASQL' has been denied. You must access this provider through a linked server.
sql语句:
INSERT INTO tablemain (UserName, UserInfo) SELECT * FROM OPENROWSET('MSDASQL', 'Driver={SQL Server};Server=*.*.*.*;uid=sa;pwd=;database=WebData', 'SELECT UserName, UserInfo FROM User_BaseInfo') AS c
该语句在我自己的服务器上测试通过。
4 个解决方案
#1
建立一个linkserver,然后select * from linkname..dbo.dbname.tblname访问
#2
--用链接服务器吧,或者用sqloledb来访问:
INSERT INTO tablemain (UserName, UserInfo) SELECT * FROM OPENROWSET('sqloledb', '*.*.*.*';'sa';'', 'SELECT UserName, UserInfo FROM WebData.dbo.User_BaseInfo') AS c
INSERT INTO tablemain (UserName, UserInfo) SELECT * FROM OPENROWSET('sqloledb', '*.*.*.*';'sa';'', 'SELECT UserName, UserInfo FROM WebData.dbo.User_BaseInfo') AS c
#3
--或者:
INSERT INTO tablemain (UserName, UserInfo) SELECT * FROM OPENROWSET('sqloledb', 'Server=*.*.*.*;uid=sa;pwd=;database=WebData', 'SELECT UserName, UserInfo FROM User_BaseInfo') AS c
INSERT INTO tablemain (UserName, UserInfo) SELECT * FROM OPENROWSET('sqloledb', 'Server=*.*.*.*;uid=sa;pwd=;database=WebData', 'SELECT UserName, UserInfo FROM User_BaseInfo') AS c
#4
zjcxc(邹建)真的佩服你,每回我的问题你都能帮上我,谢谢!结帐。
#1
建立一个linkserver,然后select * from linkname..dbo.dbname.tblname访问
#2
--用链接服务器吧,或者用sqloledb来访问:
INSERT INTO tablemain (UserName, UserInfo) SELECT * FROM OPENROWSET('sqloledb', '*.*.*.*';'sa';'', 'SELECT UserName, UserInfo FROM WebData.dbo.User_BaseInfo') AS c
INSERT INTO tablemain (UserName, UserInfo) SELECT * FROM OPENROWSET('sqloledb', '*.*.*.*';'sa';'', 'SELECT UserName, UserInfo FROM WebData.dbo.User_BaseInfo') AS c
#3
--或者:
INSERT INTO tablemain (UserName, UserInfo) SELECT * FROM OPENROWSET('sqloledb', 'Server=*.*.*.*;uid=sa;pwd=;database=WebData', 'SELECT UserName, UserInfo FROM User_BaseInfo') AS c
INSERT INTO tablemain (UserName, UserInfo) SELECT * FROM OPENROWSET('sqloledb', 'Server=*.*.*.*;uid=sa;pwd=;database=WebData', 'SELECT UserName, UserInfo FROM User_BaseInfo') AS c
#4
zjcxc(邹建)真的佩服你,每回我的问题你都能帮上我,谢谢!结帐。