在我的项目中,我使用以下代码将数据从SQL Server导出到Excel
INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0
Xml;HDR=NO;Database=D:\sathish\AA\GR_WITH_OUT_INVOICE;"IMEX=1";', SELECT *
FROM [Sheet1$C1:R]') SELECT OI_COMP,OI_MAJOUR_ACC,OI_SUB_ACC ,OI_DEPT
,OI_AIR_LINE,OI_AIR_TYPE,OI_AIR_MOD ,OI_CHANNEL,OI_PRO,OI_DIR_IND,OI_RES,
CASE WHEN CAST(OI_DEB AS NUMERIC(32,0)) = 0 THEN 00 ELSE CAST(OI_DEB AS NUMERIC(32,0)),
CASE WHEN CAST(OI_CRE AS NUMERIC(32,0))
= 0 THEN NULL ELSE CAST(OI_CRE AS NUMERIC(32,0)) END ,OI_DETAIL ,OI_MSG,''''
FROM ORCL_INTG_MACRO_GR_WITHOUT_INVOICE
ORDER BY OI_PONO,CASE WHEN OI_COMP = 'Total' then '1' else '0' end,Case when oi_deb = 0
then 0 else 1 end
此OI_CRE
和OI_DEB
是数字列,但在导出时,它们会变成字符串。如何在Excel中将数字导出为数字?
我正在使用SQL Server 2014。