Arnab's Blog

Always seeking for new technology

How to use OPENROWSET command in sql server


Dear all,

Sometimes we need to copy the data from access db to sql server. For transferring data we can use openrowset command.
For using openrowset you need the Ad Hoc Distributed Queries component turned on.
But, by default this component is being turned off for the security of server. But you can turn it on for using the openrowset command.


For turn it on you have to execute the following command in sql server……

sp_configure ‘show advanced options’,1
GO
RECONFIGURE
GO
sp_configure ‘Ad hoc distributed queries’,1
GO
RECONFIGURE

Now, you can use openrowset command. Such as…

SELECT CustomerID, CompanyName
FROM OPENROWSET(‘Microsoft.Jet.OLEDB.4.0′,
‘H:\AS.mdb’;
‘admin’;”,Customers);
GO

And again you can turned off the Ad hoc Distributed queries by following command…

sp_configure ‘Ad hoc distributed queries’,0
GO
RECONFIGURE
GO
sp_configure ‘show advanced options’,0

GO
RECONFIGURE

About these ads

One Response to How to use OPENROWSET command in sql server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

SQL Server Journey with SQL Authority

Personal Notes of Pinal Dave

Șic și clasic - "Chic & Classic" luxury fine arts, handmade work, original design

Cand cumperi arta nu cumperi doar ceea ce vezi si pipai cumperi sufletul unui om, sufletul artistului pentru ca el/ artistul s-a uitat in sufletul lui si a scos de acolo ce a gasit

A passion for Small Business

Small Business is Big Business™

geekpython

skilled with python

Follow

Get every new post delivered to your Inbox.