0
我期望在其中有自己的列,使i.ItemLookupCode, t.tostoreid, t.fromponumber, t.toloc_itemdescription, t.qtydifference
。目前,當我運行腳本時,數據全部在一列中。SQL,用於CSV的佈局
請參閱下面的當前腳本。
EXEC msdb. dbo .sp_send_dbmail @recipients= '[email protected]' ,
@profile_name = 'mymailprofile' ,
@subject ='Quantity difference ' ,
@body ='Quantity difference ' ,
@query = '
(
select i.ItemLookupCode, t.tostoreid, t.fromponumber, t.toloc_itemdescription, t.qtydifference
from
[RAMPApple] .[dbo]. [RAPurchaseOrderTransfer] t
inner join [RAMPApple] .[dbo]. [RAItems] i on t.TOLOC_ItemDescription = i.ItemDescription
where QtyDifference <> 0 and fromstoreid = 111 and t.DateCreated >= dateadd(dd, -30, GETDATE()))
' ,
@query_result_header = 1,
@attach_query_result_as_file = 1 ,
@query_attachment_filename = 'Quantity_difference.csv' ,
@query_result_separator = ' ' ,
@query_result_no_padding = 1
@query_result_separator = '',只是增加了,我只好用標籤...謝謝 – Brian 2014-09-23 17:57:10