SQL Server BCP 的数据导入导出
导入文本文件
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'
导入文本文件
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'
cmd
C:\Documents and Settings\Amy.Qiu>bcp gbldb.dbo.master in \\192.168.60.252\ReadW
riteShare\GBLDB_Master\GBLDB_Master.txt -S 192.168.60.252\SQL2005 -T -n
SQLState = 37000, NativeError = 1934
Error = [Microsoft][SQL Native Client][SQL Server]INSERT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SEToptions are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.
原因是,某个VIEW的UNIQUE CLUSTERED,删除后导入再重建
C:\Documents and Settings\Amy.Qiu>bcp gbldb.dbo.master in \\192.168.60.252\ReadW
riteShare\GBLDB_Master\GBLDB_Master.txt -S 192.168.60.252\SQL2005 -T -n
SQLState = 37000, NativeError = 1934
Error = [Microsoft][SQL Native Client][SQL Server]INSERT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SEToptions are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.
原因是,某个VIEW的UNIQUE CLUSTERED,删除后导入再重建