今天有个老朋友忽然问我一个问题,关于存储过程的。这个存储很简单:
代码
CREATE PROCEDURE Proc_InsertTemp
(
@number varchar(3000),
@name varchar(2100),
@output varchar(100) output
)
AS
BEGIN
BEGIN TRANSACTION operTran1
SET NOCOUNT ON;
DECLARE @outputerr varchar(3000)
insert into dbo.Table_1 values(@number,@name)
if @@error<>0 or @@rowcount = 0
begin
select @output = '-1'
rollback transaction operTran1
return
end
else
begin
COMMIT TRANSACTION operTran1
end
END
(
@number varchar(3000),
@name varchar(2100),
@output varchar(100) output
)
AS
BEGIN
BEGIN TRANSACTION operTran1
SET NOCOUNT ON;
DECLARE @outputerr varchar(3000)
insert into dbo.Table_1 values(@number,@name)
if @@error<>0 or @@rowcount = 0
begin
select @output = '-1'
rollback transaction operTran1
return
end
else
begin
COMMIT TRANSACTION operTran1
end
END
表Table_1的结构也很简单:
CREATE TABLE [dbo].[Table_1](
[number] [int] NULL,
[value] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL
)
[number] [int] NULL,
[value] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL
)