SQLÊý¾Ý¿âÖÐÓÃimageÀ´´æ´¢Îļþ,µ«SQLûÓÐÌṩֱ½ÓµÄ´æÈ¡ÎļþµÄÃüÁî.
/*--bcp ʵÏÖ¶þ½øÖÆÎļþµÄµ¼Èëµ¼³ö
Ö§³Öimage,text,ntext×ֶεĵ¼Èë/µ¼³ö
imageÊʺÏÓÚ¶þ½øÖÆÎļþ,°üÀ¨:WordÎĵµ,ExcelÎĵµ,ͼƬ,ÒôÀÖµÈ
text,ntextÊʺÏÓÚÎı¾Êý¾ÝÎļþ
×¢Òâ:µ¼Èëʱ,½«¸²¸ÇÂú×ãÌõ¼þµÄËùÓÐÐÐ
µ¼³öʱ,½«°ÑËùÓÐÂú×ãÌõ¼þµÄÐе¼³öµ½Ö¸¶¨ÎļþÖÐ
´Ë´æ´¢¹ý³Ì½öÓÃbcpʵÏÖ
-----------------*/
/*--µ÷ÓÃʾÀý
--Êý¾Ýµ¼³ö
exec p_binaryIO 'zj','','','acc_ÑÝʾÊý¾Ý..tb','img','c:\zj1.dat'
--Êý¾Ýµ¼Èë
exec p_binaryIO 'zj','','','acc_ÑÝʾÊý¾Ý..tb','img','c:\zj1.dat','',0
--*/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_binaryIO]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_binaryIO]
GO
Create proc p_binaryIO
@servename varchar (30),--·þÎñÆ÷Ãû³Æ
@username varchar (30), --̞
@password varchar (30), --ÃÜÂë
@tbname varchar (500), --Êý¾Ý¿â..±íÃû
@fdname varchar (30), --×Ö¶ÎÃû
@fname varchar (1000), --Ŀ¼+ÎļþÃû,´¦Àí¹ý³ÌÖÐҪʹÓÃ/¸²¸Ç:@filename+_temp
@tj varchar (1000)='', --´¦ÀíÌõ¼þ.¶ÔÓÚÊý¾Ýµ¼Èë,Èç¹ûÌõ¼þÖаüº¬@fdname,ÇëÖ¸¶¨±íÃûǰ׺
@isout bit=1 --1µ¼³ö((ĬÈÏ),0µ¼Èë
AS
declare @fname_in varchar(1000) --bcp´¦ÀíÓ¦´ðÎļþÃû
,@fsize varchar(20) --Òª´¦ÀíµÄÎļþµÄ´óС
,@m_tbname varchar(50) --ÁÙʱ±íÃû
,@sql varchar(8000)
--ÔòÈ¡µÃµ¼ÈëÎļþµÄ´óС
if @isout=1
set @fsize='0'
else
begin
create table #tb(¿ÉÑ¡Ãû varchar(20),´óС int
,´´½¨ÈÕÆÚ varchar(10),´´½¨Ê±¼ä varchar(20)
,ÉÏ´Îд²Ù×÷ÈÕÆÚ varchar(10),ÉÏ´Îд²Ù×÷ʱ¼ä varchar(20)
,ÉϴηÃÎÊÈÕÆÚ varchar(10),ÉϴηÃÎÊʱ¼ä varchar(20),ÌØÐÔ int)
insert into #tb
exec master..xp_getfiledetails @fname
select @fsize=´óС from #tb
drop table #tb
if @fsize is null
begin
print 'ÎļþδÕÒµ½'
return
end
end
--Éú³ÉÊý¾Ý´¦ÀíÓ¦´ðÎļþ
set @m_tbname='[##temp'+cast(newid() as varchar(40))+']'
set @sql='selec
ÔÚ´óÐ͵ÄÊý¾Ý¿âÓ¦ÓÃÖУ¬¾³£»áÓöµ½²¿·ÖÊý¾ÝµÄÍÑ»úºÍ¶à¸öÊý¾Ý¿âµÄºÏ²¢ÎÊÌâ¡£±ÈÈçÏÖÔÚÓÐÒ»¸öÈ«Ê¡·¶Î§Ê¹ÓõÄÓ¦ÓóÌÐò£¬Ã¿¸öÊж¼²¿ÊðÁ˵¥¶ÀµÄÏàͬµÄÓ¦ÓóÌÐò·þÎñÆ÷ºÍÊý¾Ý¿â·þÎñÆ÷£¬Ã¿¸öÔÂÐèÒª½«È«Ê¡ËùÓÐÊеÄÊý¾ÝÈ«²¿»ã×ÜÆðÀ´ÓÃÓÚ³öÈ«Ê¡µÄ±¨±í£¬ÕâÊÇÒ»Öֺܳ£¼ûµÄÊý¾Ý¿âºÏ²¢ÎÊÌâ¡£ÔÙ±ÈÈçÎÒÃÇ×öÁËÒ»¸öSmartClientµÄÓ¦ÓóÌÐò£¬Ã¿¸ö¿ ......