日期:2014-05-17 浏览次数:20511 次
insert?into?tb_zh?
SELECT *
FROM (
SELECT '商品编码' AS 商品编码,'品名规格' AS 品名规格,'颜色' AS 颜色,'计量单位' AS 计量单位,'单据号' AS 单据号,'客户名称' AS 客户名称,'单价' AS 单价,'数量' AS 数量,
'金额' AS 金额,'成本金额' AS 成本金额
UNION ALL
select?商品编码=款号,品名规格=商品#品名,颜色='',计量单位='件',单据号=单据编号,客户名称=店仓,单价=成交价,
(case?尺寸#描述?when?'4'?then?数量??end)as?'4',
(case?尺寸#描述?when?'5'?then?数量??end)as?'5',
(case?尺寸#描述?when?'6'?then?数量??end)as?'6',
(case?尺寸#描述?when?'7'?then?数量??end)as?'7',
(case?尺寸#描述?when?'8'?then?数量??end)as?'8',
数量,
金额=数量*成交价,成本金额=''
?
from?tb_daixiao
)a
exec?master..xp_cmdshell?'bcp?"SELECT?*?FROM?test.dbo.tb_zh"?queryout?"e:\1.xls"?-c?-T?-S"test"?-U"sa"?-P"sa"'