Updating an end user's expiration date. : rowcount « System Settings « SQL Server / T-SQL Tutorial






3>
4>
5>     CREATE TABLE myusers(
6>         UserID        varchar(30)NOT NULL PRIMARY KEY,
7>         FirstName     varchar(30),
8>         LastName      varchar(30),
9>         EmployeeType  char(1) NOT NULL,
10>         DBAccess      varchar(30),
11>         StartDate     datetime,
12>         ExpDate       datetime
13>     )
14>     GO
1>
2>     CREATE PROC pr_updateuser(@UserID varchar(30), @NewExpDate datetime)
3>     AS
4>     UPDATE myusers
5>          SET ExpDate = @NewExpDate
6>          Where UserID = @UserID
7>     IF @@rowcount = 1
8>          PRINT "User Updated"
9>     ELSE
10>          PRINT "Invalid UserID entered"
11>     GO
1>
2>     drop PROC pr_updateuser;
3>     GO
1>
2>     drop table myusers;
3>     GO








26.27.rowcount
26.27.1.Using the SET ROWCOUNT Option
26.27.2.Updating an end user's expiration date.
26.27.3.adds the account column to the authors table and creates the new bank and brokerage tables.
26.27.4.if @@ROWCOUNT = 0, return
26.27.5.if @@ROWCOUNT > 1, rollback
26.27.6.@@rowcount can be used to verify the success of selected operations
26.27.7.EXEC and @@ROWCOUNT