关与数据库存文件的问题?
关与数据库存文件的问题,我用了一下的语言:
EXEC master..xp_cmdshell 'bcp "SELECT * from mymodel..Users " queryout c:\DT.txt -c '
EXEC master..xp_cmdshell 'bcp "SELECT * from mymodel..Users " queryout c:\DT.txt -c -U -P '
前段时间是可以用的,可以现在突然不能用了,请教各位是什么问题引起的。
谢谢啦!
都是这种问题:
Copy direction must be either 'in ' or 'out '.
Syntax Error in 'queryout '.
usage: bcp [[database_name.]owner.]table_name[:slice_number] {in | out} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n] [-c] [-t field_terminator] [-r row_terminator]
[-U username] [-P password] [-I interfaces_file] [-S server]
[-a display_charset] [-q datafile_charset] [-z language] [-v]
[-A packet size] [-J client character set]
[-T text or image size] [-E] [-g id_start_value] [-N] [-X]
[-M LabelName LabelValue] [-labeled]
[-K keytab_file] [-R remote_server_principal]
[-V [security_options]] [-Z security_mechanism]
NULL
------解决方案--------------------LZ的SQL 我机器上可以执行,没问题,不知道为什么会报错
你试一下这个
EXEC master..xp_cmdshell 'bcp mymodel.dbo.Users out c:\DT.txt -c -U "sa " -P " " '
-----------------
-U后面的sa是登陆用户名,
-P后面引号里面是登陆密码,如果没有密码就是空
------解决方案--------------------密码:
SQLState = S0002, NativeError = 208
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]对象名 'mymodel..Users ' 无效。
SQLState = 37000, NativeError = 8180
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]未能准备语句。
NULL
------解决方案--------------------EXEC master..xp_cmdshell 'bcp "SELECT * FROM mymodel.dbo.Users " queryout c:\DT.txt -c -U "sa " -P " " '
这样试试
------解决方案--------------------SQLState = S0002, NativeError = 208
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'mymodel.dbo.Users '.
SQLState = 37000, NativeError = 8180
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.
NULL