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

Home
SQL Server / T-SQL Tutorial
1.Query
2.Insert Delete Update
3.Table
4.Table Join
5.Data Types
6.Set Operations
7.Constraints
8.Subquery
9.Aggregate Functions
10.Date Functions
11.Math Functions
12.String Functions
13.Data Convert Functions
14.Analytical Functions
15.Sequence Indentity
16.View
17.Index
18.Cursor
19.Database
20.Transact SQL
21.Procedure Function
22.Trigger
23.Transaction
24.XML
25.System Functions
26.System Settings
27.System Tables Views
28.User Role
29.CLR
SQL Server / T-SQL Tutorial » System Settings » rowcount 
26.27.2.Updating an end user's expiration date.
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(1NOT 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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.