求一存储过程写法,更新数据,

沐NeMo 2009-07-28 06:08:24
CREATE PROCEDURE ItemImgBinarySUpdate
@ItemNo nvarchar(50), --对应字段:ItemNo
@ImgBinary image=null, --对应字段:ImgBinary
@ImgBinary2nd image=null --对应字段:ImgBinary2nd
AS
主要Binary,哪一个空,就不跟新对应的字段,如果两个都有值,都更新到表ItemImgTB里面。
另外要加影响到就记录。更新成功一个或者两个字段,返回>=1。如果失败或者两个ImgBinary都为空则返回0

谢谢!
...全文
200 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
多写几个IF判断一下,应该就行了,得到影响的函数,可以使用@@RowCount
guguda2008 2009-08-29
  • 打赏
  • 举报
回复
说实话没看明白,试试小三的对不对
victorcai2006 2009-08-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 feixianxxx 的回复:]
SQL codeCREATEPROCEDURE ItemImgBinarySUpdate@ItemNonvarchar(50),--对应字段:ItemNo@ImgBinaryimage=null,--对应字段:ImgBinary@ImgBinary2ndimage=null ,--对应字段:ImgBinary2nd@nint outputASbeginif(@ImgBinaryisnotnulla¡­
[/Quote]

这个就可以了,MARK一下,自己写写看看。然后发自己的结果上来
kingtiy 2009-08-28
  • 打赏
  • 举报
回复
判断下,再插入不就可以了
沐NeMo 2009-08-28
  • 打赏
  • 举报
回复
UP
沐NeMo 2009-07-29
  • 打赏
  • 举报
回复
大家帮我看看啊。
还有
CREATE PROCEDURE ItemImgBinarySDelete
@ItemNo nvarchar(50), --对应字段:ItemNo
@ImgDeletFlag int --来更新字段:ImgBinary ImgBinary2nd =null
--Flag: 1更新第一个,2更新第二个,3两个都更新为空.
应该怎么写。
沐NeMo 2009-07-28
  • 打赏
  • 举报
回复
我是这样写的,不知道可以不,没有调试。明天自己调试看看。
CREATE PROCEDURE ItemImgBinarySUpdate
@ItemNo nvarchar(50),
@ImgBinary image=null,
@ImgBinary2nd image=null
AS
declare @RowC int
if @ImgBinary is not null
Begin
Update [ItemImgTB] Set ImgBinary=@ImgBinary Where ItemNo=@ItemNo
set @RowC=@@RowCount
End
if @ImgBinary2nd is not null
Begin
Update [ItemImgTB] Set ImgBinary2nd=@ImgBinary2nd Where ItemNo=@ItemNo
set @RowC=@RowC+@@RowCount
End
Select @RowC
GO

feixianxxx 2009-07-28
  • 打赏
  • 举报
回复
CREATE PROCEDURE ItemImgBinarySUpdate 
@ItemNo nvarchar(50), --对应字段:ItemNo
@ImgBinary image=null, --对应字段:ImgBinary
@ImgBinary2nd image=null ,--对应字段:ImgBinary2nd
@n int output
AS
begin
if(@ImgBinary is not null and @ImgBinary is null )
begin
update ItemImgTB
set ImgBinary=@ImgBinary
set @n=1
end
else if(@ImgBinary is null and @ImgBinary is not null )
begin
update ItemImgTB
set ImgBinary2nd =@ImgBinary2nd
set @n=1
end
else if(@ImgBinary is null and @ImgBinary is not null )
begin
update ItemImgTB
set ImgBinary2nd =@ImgBinary2nd ,
ImgBinary=@ImgBinary
set @n=2
end
else
set @n=0
end
飞驴 2009-07-28
  • 打赏
  • 举报
回复
image没修改过,可以用@@rowcount函数判断吧

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧