我正在尝试导出从 sql 查询生成的 xml。我正在尝试这样
EXEC master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE
EXEC master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE
EXEC xp_cmdshell 'bcp "SELECT @xml" -S <SERVERNAME> -D <DATABASE_NAME> -U <UserName> -P <PASSWORD> queryout "E:\test.xml" -T -c -t,'
在尝试这个时,我得到了下面列出的结果
Copy direction must be either 'in', 'out' or 'format'.
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"] [-x generate xml format file]
[-d database name] [-K application intent]
我无法找出问题所在。
我的问题是——
我做错了什么?
如何在驱动器中的文件中保存/导出 xml?