/* 文件名称: DeleteDemo1.sql */
USE 北风贸易
GO

EXEC sp_dboption '北风贸易','select into/bulkcopy','TRUE'
GO

SET NOCOUNT ON
GO

SELECT * INTO 我的员工
    FROM 章立民工作室

SELECT COUNT(*) FROM 我的员工

DELETE 我的员工
    WHERE 目前薪资 IN
                   (SELECT TOP 10 目前薪资 FROM 我的员工 ORDER BY 1)
                   AND DATEDIFF(yyyy,出生日期,GETDATE()) >= 26

SELECT COUNT(*) FROM 我的员工
GO

DROP TABLE 我的员工
GO

EXEC sp_dboption '北风贸易','select into/bulkcopy','FALSE'

/* 文件名称: DeleteDemo2.sql */
USE 北风贸易
GO

SET NOCOUNT ON
GO

BEGIN TRANSACTION MyTransaction

SELECT COUNT(*) FROM 客户

DELETE 客户
  WHERE 客户编号 NOT IN
       (SELECT DISTINCT 客户编号 FROM 订货主档)

SELECT COUNT(*) FROM 客户

ROLLBACK TRANSACTION MyTransaction

/* 文件名称: DeleteDemo3.sql */
USE 北风贸易
GO

SET NOCOUNT ON
GO

BEGIN TRANSACTION mytransaction

SELECT COUNT(*) FROM 飞狐工作室

DELETE 飞狐工作室
 WHERE 飞狐工作室.身份证号码 IN
    (SELECT TOP 10 身份证号码 FROM 飞狐工作室 ORDER BY 出生日期)

SELECT COUNT(*) FROM 飞狐工作室

ROLLBACK TRANSACTION mytransaction

posted on 2008-11-14 15:30  〆o殺殸纨o〆  阅读(196)  评论(0编辑  收藏  举报