SQLServer2008中,同一个存储过程执行需要有时间隔吗?为什么程序中先后执行两次,会有一次执行没效,但也不报错?
求高手解答
求高手解答
解决方案 »
- sqlserver2005 通过日志还原数据库?
- 急,能发个图片看下C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data里面的数据库图标吗?
- 分离数据库后的mdf那去了?
- 问题急,求一条sql语句,实现这样的功能,高手们请进!有分贡上!。。。。。。。。。。。。。
- SQL2008 DMV
- 急求解答:SQL2005安装问题!
- 超急急,在线等,高手一定要帮个忙呀!
- SQL语句的用法,高手看过来
- 有谁碰到过DTS在通过作业执行包时老失败的问题吗
- 关于删除的问题!帮帮忙!
- sql server2000安装后没有自带的数据库怎么办
- sql 2005从excel 2007查询数据出错,请大家指点指点
@UserId int,
@DataType int,
@DataValue int
AS
begin
SET NOCOUNT ON
if exists( select UserId from T_UserData where UserId = @UserId and DataType = @DataType )
begin
update T_UserData set DataValue = @DataValue where UserId = @UserId and DataType = @DataType
end
else
begin
insert into UserId ( UserId , DataType, DataValue )
values ( @UserId , @DataType, @DataValue )
end
return @@ERROR
end
你执行第二次,数据是不会有变化的。
改成下面的肯定就能看出来效果了ALTER PROCEDURE [dbo].[P_DataUpdate]
@UserId int,
@DataType int,
@DataValue int
AS
begin
SET NOCOUNT ON
if exists( select UserId from T_UserData where UserId = @UserId and DataType = @DataType )
begin
update T_UserData set DataValue = 'xxoo' where UserId = @UserId and DataType = @DataType
end
else
begin
insert into UserId ( UserId , DataType, DataValue )
values ( @UserId , @DataType, @DataValue )
end
return @@ERROR
end
@UserId int,
@DataType int,
@DataValue int
AS
begin
SET NOCOUNT ON
if exists( select UserId from T_UserData where UserId = @UserId and DataType = @DataType )
begin
update T_UserData set DataValue = @DataType where UserId = @UserId and DataType = @DataType
print 'update'
end
else
begin
insert into UserId ( UserId , DataType, DataValue )
values ( @UserId , @DataType, @DataValue )
print 'insert'
end
return @@ERROR
end