日期:2014-05-17 浏览次数:20547 次
--开启xp_cmdshell
sp_configure 'show advanced options', 1
go
reconfigure
go
sp_configure 'xp_cmdshell', 1
go reconfigure
go
--导出到TXT文本
EXEC master..xp_cmdshell 'bcp dbname..tablename out c:/DT.txt -c -Sservername -Usa -Ppassword'
或
EXEC master..xp_cmdshell 'bcp "Select * from dbname..tablename" queryout c:/DT.txt -c -Sservername -Usa -Ppassword'
--导出到Access
insert into OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source=" c:\DB.mdb";User ID=Admin;Password=')...表名 (列名1,列名2) select 列名1,列名2 from sql表