BCP:xls,Doc,jpg文件无法转换数据,而双击显示erro就像损坏一样 [英] BCP:xls,Doc,jpg files unable to convert data,while double clicking showing erro like corrupted

查看:116
本文介绍了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 =''eis_fsdf@fsdfsd.com'',

@ recipients =' 'sfsfsd@fsd.com'',

@copy_recipients =''fsfs@fs.com'',

@ subject =''test'',

@ body =''测试'',

@body_format =''html'',

@file_attachments = @ filepath


exec master.sys.xp_cmdshell @BCPCommand

EXEC msdb.dbo.sp_send_dbmail
@from_address = ''eis_fsdf@fsdfsd.com'',
@recipients= ''sfsfsd@fsd.com'',
@copy_recipients = ''fsfs@fs.com'',
@subject= ''test'',
@body= ''testing'' ,
@body_format = ''html'',
@file_attachments =@filepath

推荐答案

我最后在BCP中提交了这段代码,它会打开所有类型的文件





select @BCPCommand =''bcp从databasename.dbo.tbl_Log中选择TOP 1 cast(cast(documentContent as varbinary(max))as varchar(max))其中documentTypeId = sfsd和requestId = fsdqueryout''+ @filepath + ''-T -c -r \ n -CACP -SServer \ Instance name -V(100)''





欲了解更多信息,请参阅此链接....

http://www.tek -tips.com/viewthread.cfm?qid=545711 [ ^ ]





感谢上帝最后我做了:))
HI i Finally submitted this code in BCP,it opens all types of files


select @BCPCommand=''bcp "select TOP 1 cast(cast(documentContent as varbinary(max)) as varchar(max)) from databasename.dbo.tbl_Log where documentTypeId=sfsd and requestId =fsd " queryout '' + @filepath + '' -T -c -r\n -CACP -SServer\instance name -V(100)''


For more refer this link....
http://www.tek-tips.com/viewthread.cfm?qid=545711[^]


Thank God Finally i did :)


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆