34,838
社区成员




exec master..xp_cmdshell
'bcp
"SELECT convert(char(20),isnull(item_no,''))
+convert(char(20),isnull(item_subname,''))
+convert(char(20),isnull(item_size,''))
+case
when convert(int,round(price,2)*100)%100= 0
then convert(char(9),convert(dec(9,0),price))
when convert(int,round(price,2)*100)%10=0
then convert(char(9),convert(dec(8,1),price))
else convert(char(9),convert(dec(7,2),price)) end
+case
when convert(int,round(sale_price,2)*100)%100=0
then convert(char(9),convert(dec(9,0),sale_price))
when convert(int,round(sale_price,2)*100)%10=0
then convert(char(9),convert(dec(8,1),sale_price))
else convert(char(9),convert(dec(7,2),sale_price)) end
+convert(char(8),item_clsno)+''0'','',''
FROM t_bd_item_info
where item_clsno like ''%''"
queryout c:\1.txt -c -U"sa" -P"" '
exec master..xp_cmdshell'bcp "select * from test.dbo.ttt" queryout c:\1.txt -c -T'
exec master..xp_cmdshell'bcp "select * from 数据库.所有者.表名" queryout c:\1.txt -c -T'
exec master..xp_cmdshell 'bcp "你的sql" queryout 路径 -c -U"用户" -P"密码"'