Access data import sqlserver2008r2

Source: Internet
Author: User

Environment: Office Access 2010+sqlserver2008r2+windows Server 2008R2

MODE: Transact-SQL

Method:

1. Query access data in SQL Server:

1 SELECT * 2 3  from OpenDataSource ' microsoft.ace.oledb.12.0 ' , 4 5 ' Data source= "C:\DB.mdb"; User id=; password=') ... Table name         

2. Import access to SQL Server

1 SELECT * 2 3  into newtable 4 5  from opendatasource ('microsoft.ace.oledb.12.0',6 7 ' Data source= "C:\DB.mdb"; User id=; password=' ) ... Table name            

3. Insert data from the SQL Server table into an Access table

1 Insert  into OpenDataSource ' microsoft.jet.oledb.4.0 ' , 2 3 ' Data source= "C:\DB.mdb"; User id=; password=') ... Table name 45  (column name 1, column name 2)67Select from SQL table        

Problem:

1. How to keep the identity column values intact:

When there is an auto-grow column, the insert prompts: You can specify an explicit value for the Identity column in table ' XXX ' only if the column list is used and Identity_insert is on.

1       Set Identity_insert [INFO]  on2 3       INSERT  into [Sdedb].[dbo].[INFO] 4([ID] 5,[NAME])6       SELECT7       [ID] 8,[NAME]9        from OpenDataSource('microsoft.ace.oledb.12.0',Ten       'Data source= "C:\DB. ACCDB "; User id=; password=')...[INFO]; One       Set Identity_insert [INFO] off A GO
View Code

2. SQL Server blocked access to the STATEMENT ' Openrowset/opendatasource ' of the component ' Ad Hoc distributed Queries '

Run the following SQL statement to enable AD Hoc distributed Queries:

1 exec ' Show advanced Options ',12reconfigure3exec'Ad Hoc Distributed Queries',14reconfigure

Run the following SQL statement to close the ad Hoc distributed Queries:

1 exec ' Ad Hoc Distributed Queries ',02reconfigure3exec'Show advanced options  ',04reconfigure

3, install Accessdatabaseengine_x64.exe, otherwise cannot find the database engine

Access data import sqlserver2008r2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.