Archiving end user data. : Delete Statement « Transact SQL « 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 » Transact SQL » Delete Statement 
20.14.1.Archiving end user data.
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(1NOT 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(1NOT 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
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.