高分求sqlserver写excel - MS-SQL Server / 疑难问题
1.怎么把数据从sqlserver里面的数据写入到指定路径的excel
比如
declare @公司名称 char(50)
set @公司名称 = (select 公司名称 from 公司信息)
EXEC [master]..xp_cmdshell 'bcp "select * from [master].tab_a" queryout D:\'+ convert(varchar,@公司名称)+'\ssss.xls -c -q -S"." -U"sa" -P"123456"'
但是总是报
消息 102,级别 15,状态 1,第 68 行
'+' 附近有语法错误。
我用下面语句也报同样的错误
insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 8.0;IMEX=0;HDR=YES;DATABASE=d:\'+convert(varchar,rtrim(@公司名称))+'\ssss.xls',[Sheet1$])
select * from tab_a
2、如何在上一句的基础上将结果插入到指定的单元格内
比如我要将数据写到ssss.xls,sheet1的B3单元格内
谢谢各位大侠
相关问答:
执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
第一句:
select ht.gfdm,gfdm.gfmc,gfdm.lb ,sum(jh.htdj*jh.htsl)as je
from ht left join gfdm on ht.gfdm=gfdm.gfdm
join jh on ht.htbh=jh.hth
and ht.htbh not like'del%' and ht. ......
id url rank ......