2024年4月8日发(作者:)

sqlserver数据的导入导出命令

sql server 数据的导入导出命令

一、将.dbf(foxpro数据文件)导入到sql server中:

-------------如果接受导入数据的SQL表不存在,导入时创建

select * into 要生成的SQL表

名 from openrowset('MSDASQL','Driver=Microsoft Visual FoxPro Driver;Sou

rceType=DBF;SourceDB=c:','select * from dbf表名.DBF')

实例:

--导入mdf数据文件

select * into t_tdd from openrowset('MSDASQL',

'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=d:我的文

档桌面宁夏第一次数据','select * from [t_]')

在执行命令前,要下载了一个microsoft ole db provider for visual foxpro安装,

可以了。

在使用该命令时,有时会出现如下错误提示:

SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的

STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全

配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc

Distributed Queries'。有关启用 'Ad Hoc Distributed Queries' 的详细信息,请参阅

SQL Server 联机丛书中的 "外围应用配置器"。

查询相关资料,找到解决方法:

启用Ad Hoc Distributed Queries:

exec sp_configure 'show advanced options',1

reconfigure

exec sp_configure 'Ad Hoc Distributed Queries',1

reconfigure

使用完成后,关闭Ad Hoc Distributed Queries:

exec sp_configure 'Ad Hoc Distributed Queries',0

reconfigure

exec sp_configure 'show advanced options',0