- 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');
- -- Delete a record from our Table Variable.
- DELETE FROM @UserAccounts
- WHERE firstName = 'John';
- -- Selecting the records from our Table Variable.
- SELECT * FROM @UserAccounts;
The output of this query should be:
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
firstName lastName
-------------------------------------------------- --------------------------------------------------
Jane Doe
Jim Doe
(2 row(s) affected)
No comments:
Post a Comment