How to check if value is inserted successfully or not?

前端 未结 4 792
栀梦
栀梦 2021-02-01 17:16

I have a procedure where I insert values into my table.

declare @fName varchar(50),@lName varchar(50),@check tinyint
INSERT INTO myTbl(fName,lName) values(@fName         


        
4条回答
  •  情歌与酒
    2021-02-01 17:45

    you can use @@rowcount after insert table

    DECLARE @check int

    INSERT INTO Employees (Name,Email,Phone,[Address]) VALUES('Test','test@mail.com','','')

    if(@@ROWCOUNT>0) SET @check=1

    SELECT @check;

提交回复
热议问题