Archiving end user data. : Delete Statement « Transact SQL « SQL Server / T-SQL Tutorial






5>
6>
7>     CREATE TABLE myusers(
8>         UserID        varchar(30)NOT NULL PRIMARY KEY,
9>         FirstName     varchar(30),
10>         LastName      varchar(30),
11>         EmployeeType  char(1) NOT NULL,
12>         DBAccess      varchar(30),
13>         StartDate     datetime,
14>         ExpDate       datetime
15>     )
16>     GO
1>     CREATE TABLE oldusers(
2>         UserID         varchar(30),
3>         FirstName      varchar(30),
4>         LastName       varchar(30),
5>         EmployeeType   char(1) NOT NULL,
6>         DBAccess       varchar(30),
7>         StartDate      datetime,
8>         ExpDate        datetime
9>     )
10>     GO
1>
2>     CREATE PROC pr_copyuser (@UID varchar(30) )
3>     AS
4>     INSERT INTO oldusers SELECT * FROM myusers WHERE UserID = @UID
5>     DELETE myusers WHERE UserID = @UID
6>     GO
1>
2>     drop PROC pr_copyuser;
3>     GO
1>
2>
3>     drop table oldusers;
4>     drop table myusers;
5>     GO








20.14.Delete Statement
20.14.1.Archiving end user data.
20.14.2.Creation Script for the usp_EmployeeDelete Stored Procedure
20.14.3.Delete record in a stored procedure by parameter
20.14.4.Dynamic Deletes
20.14.5.Deleting Rows in Chunks