SqlServer2008 导入导出txt或Execl数据

--右键user表所在的数据库,然后任务--导出数据,然后根据提示设置就行
--从txt中导入
EXEC master..xp_cmdshell 'bcp Northwind.dbo.sysusers in c:\1.txt -c -Sservername -Usa -Ppassword' 
--用帐户密码连接方式,导出表所有数据
EXEC master..xp_cmdshell 'bcp Northwind.dbo.sysusers out c:\1.txt -c -q -Usa  -Ppassword' 
--用帐户密码连接方式,导出查询数据
EXEC master..xp_cmdshell 'bcp "select name from Northwind.dbo.sysusers" queryout c:\1.txt -c -q -Usa  -Ppassword' 
--用信任连接方式导出
EXEC master..xp_cmdshell 'bcp "select name from Northwind.dbo.sysusers" queryout c:\1.txt -c -T'

posted @ 2015-04-17 14:15  深南大道  阅读(619)  评论(0编辑  收藏  举报