本文介绍了BCP:xls,Doc,jpg文件无法转换数据,而双击显示erro就像损坏一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< - >





您好我正在使用BCP方法使用BCP将文件内容复制到服务器文件夹中,并通过文件在sp_send_dbmail中保存为附件的服务器路径。



我的问题是.xls,.doc,.jpg文件以外的所有文件都无法显示确切的文件。提示它显示文件已损坏的消息。



任何人帮助我

使用这样的代码同时通过BCP将文件保存到服务器中。 />


<->


Hi Im using BCP method for copying file content into server folder using BCP,and passing the server path where file saved as attachment in sp_send_dbmail.

My problem is All files except .xls,.doc,.jpg files cant show the exact files.after opening the file it showing file corrupted message.

Anyone help me out
im using code like this while saving file through BCP into server.

declare @Filename nvarchar(255),@SQL varchar(8000),@Id varchar(255),@requestID varchar(255),@filepath nvarchar(255),@BCPCommand nvarchar(255)
--set @requestID ='1416'
set @filepath ='F:\CCL\File.xls'
select @Filename=(select documentName from tbl_vxcv_Log where documentTypeId=4 and requestId =@requestID)







select @BCPCommand='bcp "select TOP 1 cast(cast(documentContent as varbinary(max)) as varchar(max))  from CARSCHEME_BPRSQL8.dbo.tbl_vxcv_Log where documentTypeId=4 and requestId =1416"  queryout ' + @filepath  + ' -T -n  -CACP -S1serverIP -V(100)'



exec master.sys.xp_cmdshell @BCPCommand



EXEC msdb.dbo.sp_send_dbmail

@from_address =''[email protected]'',

@ recipients =' '[email protected]'',

@copy_recipients =''[email protected]'',

@ subject =''test'',

@ body =''测试'',

@body_format =''html'',

@file_attachments = @ filepath


exec master.sys.xp_cmdshell @BCPCommand

EXEC msdb.dbo.sp_send_dbmail
@from_address = ''[email protected]'',
@recipients= ''[email protected]'',
@copy_recipients = ''[email protected]'',
@subject= ''test'',
@body= ''testing'' ,
@body_format = ''html'',
@file_attachments =@filepath

推荐答案


这篇关于BCP:xls,Doc,jpg文件无法转换数据,而双击显示erro就像损坏一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 10:50