现在的位置: 首页 > 综合 > 正文

如何利用存储过程插入更新IMAGE数据类型

2012年09月02日 ⁄ 综合 ⁄ 共 1342字 ⁄ 字号 评论关闭

数据库表对于字段IMAGE数据类型如何进行插入或者更新。

对于插入比较简单可以用INSERT语句

 

 

CREATE PROCEDURE uf_chw_cpflInfoInsert
 -- Add the parameters for the stored procedure here
@flLevel as MyVarchar50,
@lbMc as MyVarchar50,
@lbXh as MyVarchar50,
@flZjm as MyVarchar50,
@lbTx as MyImage
AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;
    -- Insert statements for procedure here
    INSERT INTO [chw_cpflInfo]
           ([flLevel]
           ,[lbMc]
           ,[lbXh]
           ,[flZjm]
           ,[lbTx])
     VALUES
           (@flLevel,@lbMc,@lbXh,@flZjm,@lbTx)

END

更新:

 CREATE PROCEDURE uf_chw_cpflInfoUpdate
 -- Add the parameters for the stored procedure here

@lbBh as MyIdentity,
@flLevel as MyVarchar50,
@lbMc as MyVarchar50,
@lbXh as MyInt,
@flzjm as MyVarchar50,
@lbTx as MyImage

AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;
    -- Insert statements for procedure here
update  chw_cpflinfo
        set fllevel=@fllevel,
        lbmc=@lbMc,
        lbXh=@lbXh,
        flzjm=@flZjm,
        lbTx=@lbTx
        where lbbh=@lbbh 
EXEC sp_dboption 'chemicalweb', 'select into/bulkcopy', 'true'  

-- 当为 true 时,允许使用 SELECT INTO 语句和快速大容量复制。

DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(lbtx) from chw_cpflinfo where lbbh=@lbbh
--UPDATETEXT chw_cpflinfo.lbtx @ptrval null null @lbTx
WRITETEXT   chw_cpflinfo.lbtx @ptrval @lbTx
EXEC sp_dboption 'chemicalweb', 'select into/bulkcopy', 'false'

 

  
END

抱歉!评论已关闭.