SQL Server and Access data read and write

Source: Internet
Author: User
Tags db2

1.ways to query data in Access:

SELECT * from OpenRowSet (' microsoft.jet.oledb.4.0 ', ';d-atabase=c:/db2.mdb ', ' select * from Serv_user ')

or select * from OpenDataSource (' microsoft.jet.oledb.4.0 ', ' Data source= ' C:/db2.mdb "; User id=admin; Password= ')

2.to write data from SQL Server to access:

Insert into OpenRowSet (' microsoft.jet.oledb.4.0 ', ';d atabase=c:/db2.mdb ', ' SELECT * from Accee table ')
SELECT * From SQL Server table

or with Bcpmaster. xp_cmdshell ' bcp ' serv-htjs.dbo.serv_user "out" C:/db3.mdb "-c-q-S". "-U" sa "-P" sa "

The main difference is that OPENROWSET requires MDB and table presence, and BCP generates the MDB when it does not exist.

3.to write data from access to SQL Server:

With the basics, it's easy.

INSERT INTO SQL Server table select * FROM
OpenRowSet (' microsoft.jet.oledb.4.0 ', ';d atabase=c:/db2.mdb ', ' SELECT * from Accee table ')

or with bcp

Master.. xp_cmdshell ' bcp ' Serv-htjs.dbo.serv_user "in" C:/db3.mdb "-c-q-S". "-U" sa "-P" sa "

4.Delete Access data:

Delete from OpenRowSet (' microsoft.jet.oledb.4.0 ', ';d-atabase=c:/db2.mdb ', ' select * from Serv_user ')
where lock=0

5.To Modify Access data:

Update OpenRowSet (' microsoft.jet.oledb.4.0 ', ';d atabase=c:/db2.mdb ', ' select * from Serv_user ')
Set Lock=1

SQL Server and Access data read and write

Related Article

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.