请教各位大哥:以文本格式实现Sqlserver中表导入导出的代码咋写?!
如题!
谢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
问题点数:0、回复次数:2Top
1 楼aohan(aohan)回复于 2004-12-03 22:22:01 得分 0
/** 导入文本文件
EXEC master..xp_cmdshell 'bcp dbname..tablename in c:\DT.txt -c -Sservername -Usa -Ppassword'
/** 导出文本文件
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'
导出到TXT文本,用逗号分开
exec master..xp_cmdshell 'bcp "库名..表名" out "d:\tt.txt" -c -t ,-U sa -P password'
Top
2 楼aohan(aohan)回复于 2004-12-03 22:35:06 得分 0
另外你也可以用打开文本,读取行再分解的方式来实现Top




