- USE master;
- GO
- -- The creation of our Table Variable.
- DECLARE @UserAccounts TABLE
- (
- firstName VARCHAR(50)
- , lastName VARCHAR(50)
- );
- -- Inserting 3 records into our Table Variable.
- INSERT INTO @UserAccounts
- VALUES ('John', 'Doe');
- INSERT INTO @UserAccounts
- VALUES ('Jane', 'Doe');
- INSERT INTO @UserAccounts
- VALUES ('Jim', 'Doe');
- -- Update a record from our Table Variable.
- UPDATE @UserAccounts
- SET firstName = 'This is an unrealistic name.'
- WHERE firstName = 'Jim';
- -- Selecting the records from our Table Variable.
- SELECT * FROM @UserAccounts;
The result of this query should be:
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
firstName lastName
-------------------------------------------------- --------------------------------------------------
John Doe
Jane Doe
This is an unrealistic name. Doe
(3 row(s) affected)
No comments:
Post a Comment