将存储过程的现有参数更改为输出参数是否会对现有代码产生任何影响?
对于上下文,我有一个存储过程,它接受然后修改一个参数,通过选择它返回修改后的参数。C# 调用者通过SqlCommand.ExecuteReader
.
存储过程如下所示:
CREATE procedure UpsertData
@objectid int, --This line would change
...
as
if not exists (select objectid from mytable where objectid = @objectid)
begin
insert into mytable (...) values (...)
set @objectid = (select scope_identity() as int)
end
else
begin
update mytable
set ...
where objectid=@objectid
end
select @objectid
我现在打算在其他存储过程中调用这个存储过程。使用INSERT-EXEC可以让我避免修改UpsertData
在多个地方使用的 .
但是,它让我觉得@objectid int,
用@objectid int output,
. 我不确定这是否安全;存储过程在很多地方都被调用,所以我担心它可能会以某种意想不到的方式中断。 这是一个合理的担忧吗?