日期:2014-05-18  浏览次数:20389 次

MSSQL和ACCESS数据转换,如何加入WHERE条件的呢? 语法是怎么样的?
如下的SQL语句,如何加入WHERE条件的呢? 语法是怎么样的?

INSERT INTO [dbo].[sh_diqu] ([id],[diqu],[self1],[self2]) 
 SELECT [id],[diqu],[self1],[self2] 
 FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source="G:\tools\CreateSql\liehuonet\custom.mdb"')...[sh_diqu]

语法可以是这样的吗?
INSERT INTO [dbo].[sh_diqu] ([id],[diqu],[self1],[self2]) 
 SELECT [id],[diqu],[self1],[self2] 
 FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source="G:\tools\CreateSql\liehuonet\custom.mdb"')...[sh_diqu] where self1='华东地区'

------解决方案--------------------
SQL code

将SQL SERVER表里的数据插入到Access表中
-- ======================================================
在SQL SERVER 里运行:
insert into OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
  'Data Source=" c:\DB.mdb";User ID=Admin;Password=')...表名 
(列名1,列名2)
select 列名1,列名2  from  sql表

实例:
insert into  OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
   'C:\db.mdb';'admin';'', Test) 
select id,name from Test
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'c:\trade.mdb'; 'admin'; '', 表名)
SELECT *
FROM sqltablename


insert into  OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source="D:\db.mdb";User ID=Admin;Password=')...Student(studentid,name) select staffid,name from staff
insert into  OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
   'D:\db.mdb';'admin';'', Student) 
select accountid,name from tblbaccount

select * from openrowset('Microsoft.Jet.OLEDB.4.0','D:\db.mdb';'admin';'',Student)