SQL导出到文本,文本导入到表

      SQL导出到文本:

exec master..xp_cmdshell ' bcp "库名..表名" out "文件路径和名称" -c  -U "用户名"  -P "密码" '

    例如:

exec master..xp_cmdshell ' bcp "Northwind..Region" out "d:\tt.txt" -c  -U "sa"  -P "sa" '

     SQL文本导入到表

exec master..xp_cmdshell ' bcp "库名..表名" in "文件路径和名称" -c  -U "用户名"  -P "密码" '

例如:

exec master..xp_cmdshell ' bcp "Northwind..tb" in "d:\tt.txt" -c -U "sa"  -P "sa" '

Permalink | Comments (1) | Hits: 800 | Time: 10:47:16
重命名数据库
如何使用vs2005自带的sql2005
All Comments
#1 - Woody - 2008-5-22 17:19:49
DECLARE @result int
exec @result = master..xp_cmdshell ' bcp stgylN1ew..gyl_xiaoban2 in tb.txt -c -U sa -P sa '
select @result
Post Your Comment
^ ^

Top