日期:2014-05-18  浏览次数:20563 次

错误:当前事务未能导出到远程提供程序
写了1个导出到EXCEL的存储过程,存储过程没问题,但在JAVA中调用老报下面

的错误:“当前事务未能导出到远程提供程序。已回滚了该事务。”,监视

JAVA执行SQL语句,然后把这个SQL语句在查询分析器中执行都没问题,请问大

家这是什么原因,谢谢

------解决方案--------------------
--导出excel处理
declare @s nvarchar(4000)
set @s= 'bcp " '+
+N 'select top 100 percent '
+N ' case c.colid when 1 then o.name else N ' ' ' ' end as 表名, '
+N ' c.colid as 序号, '
+N ' c.name as 字段名, '
+N ' t.name 数据类型, '
+N ' c.prec as 长度, '
+N ' p.value as 字段说明, '
+N ' m.text as 默认值 '
+N ' from '+quotename(@dbname)+N '.dbo.sysobjects o '
+N ' inner join '+quotename(@dbname)+N '.dbo.syscolumns c on o.id=c.id '
+N ' inner join '+quotename(@dbname)+N '.dbo.systypes t on c.xusertype=t.xusertype '
+N ' left join '+quotename(@dbname)+N '.dbo.sysproperties p on c.id=p.id and c.colid = p.smallid '
+N ' left join '+quotename(@dbname)+N '.dbo.syscomments m on c.cdefault=m.id '
+N ' where o.xtype in(N ' 'U ' ') and o.status> =0 '
+N ' order by c.id,c.colid '
+N ' " queryout " '+@fname
+N ' " /P " " /w '
exec master..xp_cmdshell @s,no_output
go


------解决方案--------------------
怎样解决的?贴出来,看看~