none
sql语句导出excel RRS feed

  • 问题

  • xp_cmdshell bcp queryout导出excel                 
    查询语句用union出错
    'SELECT ''产品名称'',''产品型号'',''产品规格'',''材质'',''单价'',''数量'',''重量'',''备注'' FROM ##tab union all SELECT ProductName,ProductModel,GuiGe,Material,Price,Quantity,Weight,Description FROM ##tab'
    有没有办法解决
    2009年5月8日 2:59

答案

  • SELECT ProductName as "产品名称",ProductModel as "产品型号",GuiGe as "产品规格",Material as "材质",Price as "单价",Quantity as "数量",Weight as "重量",Description as "备注" FROM ##tab union all
    SELECT ProductName as "产品名称",ProductModel as "产品型号",GuiGe as "产品规格",Material as "材质",Price as "单价",Quantity as "数量",Weight as "重量",Description as "备注" FROM ##tab
    -- 多个union 之间的语句列名最好一样
    知识改变命运,奋斗成就人生!
    2009年5月9日 2:48
    版主

全部回复

  • 你的帖子发错位置了,换换栏目,会有人回答你的。
    做最好的自己
    2009年5月8日 14:33
  • SELECT ProductName as "产品名称",ProductModel as "产品型号",GuiGe as "产品规格",Material as "材质",Price as "单价",Quantity as "数量",Weight as "重量",Description as "备注" FROM ##tab union all
    SELECT ProductName as "产品名称",ProductModel as "产品型号",GuiGe as "产品规格",Material as "材质",Price as "单价",Quantity as "数量",Weight as "重量",Description as "备注" FROM ##tab
    -- 多个union 之间的语句列名最好一样
    知识改变命运,奋斗成就人生!
    2009年5月9日 2:48
    版主