修改这个存储过程。

Transitional 2008-06-03 09:30:52

ALTER PROCEDURE [dbo].[P_Chat_Sel_Update]
@itID int,
@strPid nvarchar(50),
@strMstTo nvarchar(50)
AS
BEGIN
select top 1 ID,msg,date from chat where pid=@strPid and msgTo=@strMstTo and isread=0
--参数@itID等于上面查询出来的ID,上面那个查询任然要执行出结果
set @itID=???
UPDATE chat set isread=1 where ID =208;
END
...全文
58 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Transitional 2008-06-03
  • 打赏
  • 举报
回复
perfectaction
你的过程不可用,要先查询 然后再更新 谢谢
Transitional 2008-06-03
  • 打赏
  • 举报
回复
好吧 如果要多写一行 我早写了,晕。
nzperfect 2008-06-03
  • 打赏
  • 举报
回复
ALTER PROCEDURE [dbo].[P_Chat_Sel_Update] 
@itID int,
@strPid nvarchar(50),
@strMstTo nvarchar(50)
AS
BEGIN
select top 1 @itID=ID from chat where pid=@strPid and msgTo=@strMstTo and isread=0
UPDATE chat set isread=1 where ID =@itID
select top 1 ID,msg,date from chat where pid=@strPid and msgTo=@strMstTo and isread=0
END


多写一行不可以吗?
昵称被占用了 2008-06-03
  • 打赏
  • 举报
回复
ALTER PROCEDURE [dbo].[P_Chat_Sel_Update]
@itID int output,
@strPid nvarchar(50),
@strMstTo nvarchar(50)
AS
BEGIN
select top 1 @itID=ID from chat where pid=@strPid and msgTo=@strMstTo and isread=0
select top 1 ID,msg,date from chat where pid=@strPid and msgTo=@strMstTo and isread=0
UPDATE chat set isread=1 where ID =208;
END
nzperfect 2008-06-03
  • 打赏
  • 举报
回复
ALTER PROCEDURE [dbo].[P_Chat_Sel_Update]
@itID int,
@strPid nvarchar(50),
@strMstTo nvarchar(50)
AS
BEGIN
select top 1 @itID=ID,msg,date from chat where pid=@strPid and msgTo=@strMstTo and isread=0
select top 1 ID,msg,date from chat where pid=@strPid and msgTo=@strMstTo and isread=0
UPDATE chat set isread=1 where ID =208;
END
Transitional 2008-06-03
  • 打赏
  • 举报
回复
一定要
select top 1 ID from chat where pid = @strPid and msgTo = @strMstTo and isread = 0
吗?
在这个里面可以吗?这样我就只用写一句就可以了。
select top 1 ID,msg,date from chat where pid=@strPid and msgTo=@strMstTo and isread=0
sweetweiwei 2008-06-03
  • 打赏
  • 举报
回复
--try
set @itID = (select top 1 ID from chat where pid = @strPid and msgTo = @strMstTo and isread = 0)
Transitional 2008-06-03
  • 打赏
  • 举报
回复
没有写完整,
更行语句如下。
UPDATE chat set isread=1 where ID =@itID;

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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