You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.5 KiB
121 lines
2.5 KiB
|
|
|
|
use chongqing_qipin
|
|
|
|
EXEC sp_password 'qipin_sz24_~!@#','qipin_sz24_~!@#_','qipin'
|
|
|
|
EXEC sp_password 'qipin_sz24_~!@#_','qipin_sz24_~!@#','qipin'
|
|
|
|
|
|
CREATE TABLE TQPMonitor
|
|
(
|
|
FId INT IDENTITY(1,1) PRIMARY KEY,
|
|
FTableName VARCHAR(200),
|
|
FDataId BIGINT,
|
|
FAction VARCHAR(20),
|
|
FStatus INT,
|
|
)
|
|
|
|
GO
|
|
|
|
IF OBJECT_ID('PCreateMonitorTrigger') IS NOT NULL
|
|
DROP PROC PCreateMonitorTrigger
|
|
GO
|
|
|
|
CREATE PROC PCreateMonitorTrigger
|
|
(
|
|
@Table VARCHAR(200),
|
|
@Key VARCHAR(200)
|
|
)
|
|
AS
|
|
BEGIN
|
|
DECLARE @name VARCHAR(200)
|
|
SELECT @name = 'TRQPInsert' + SUBSTRING(@Table,2,LEN(@Table))
|
|
PRINT @name
|
|
EXEC('
|
|
IF OBJECT_ID('''+@name+''') IS NOT NULL
|
|
DROP TRIGGER '+@name)
|
|
|
|
EXEC('
|
|
CREATE TRIGGER '+@name+'
|
|
ON '+@table+'
|
|
FOR INSERT
|
|
AS
|
|
BEGIN
|
|
INSERT TQPMonitor(FTableName,FDataId,FAction,FStatus)
|
|
SELECT '''+@table+''','+@key+',''Insert'',0
|
|
FROM inserted
|
|
END
|
|
')
|
|
|
|
SELECT @name = 'TRQPDelete' + SUBSTRING(@Table,2,LEN(@Table))
|
|
PRINT @name
|
|
EXEC('
|
|
IF OBJECT_ID('''+@name+''') IS NOT NULL
|
|
DROP TRIGGER '+@name)
|
|
|
|
EXEC('
|
|
CREATE TRIGGER '+@name+'
|
|
ON '+@table+'
|
|
FOR DELETE
|
|
AS
|
|
BEGIN
|
|
INSERT TQPMonitor(FTableName,FDataId,FAction,FStatus)
|
|
SELECT '''+@table+''','+@Key+',''Delete'',0
|
|
FROM deleted
|
|
END
|
|
')
|
|
END
|
|
GO
|
|
|
|
EXEC PCreateMonitorTrigger 'TItem','FId'
|
|
EXEC PCreateMonitorTrigger 'TGoods','FId'
|
|
EXEC PCreateMonitorTrigger 'TBasicType','FId'
|
|
EXEC PCreateMonitorTrigger 'TMemberCardType','FId'
|
|
EXEC PCreateMonitorTrigger 'TMember','FMemId'
|
|
EXEC PCreateMonitorTrigger 'TMemberCard','FCardId'
|
|
|
|
|
|
|
|
SELECT * FROM
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
DELETE TQPMonitor
|
|
|
|
DROP TABLE #Item
|
|
|
|
SELECT TOP 1 * INTO #Item FROM TItem
|
|
|
|
UPDATE #Item SET FId = dbo.FNNewId(),FNO = dbo.FNNewId(),FNOOfPad = dbo.FNNewId()
|
|
|
|
EXEC PCopyTable 'TItem','#Item',''
|
|
DELETE TItem WHERE FId IN(SELECT FId FROM #Item)
|
|
SELECT * FROM TQPMonitor
|
|
|
|
|
|
DROP TABLE #Goods
|
|
SELECT TOP 1 * INTO #Goods FROM TGoods
|
|
UPDATE #Goods SET FId = dbo.FNNewId(),FNO = dbo.FNNewId(),FNOOfPad = dbo.FNNewId()
|
|
EXEC PCopyTable 'TGoods','#Goods',''
|
|
DELETE TGoods WHERE FId IN(SELECT FId FROM #Goods)
|
|
SELECT * FROM TQPMonitor
|
|
|
|
|
|
DROP TABLE #Member
|
|
SELECT TOP 1 * INTO #Member FROM TMember
|
|
UPDATE #Member SET FMemId = dbo.FNNewId(),FMemNo = dbo.FNNewId()
|
|
EXEC PCopyTable 'TMember','#Member',''
|
|
DELETE TMember WHERE FMemId IN(SELECT FMemId FROM #Member)
|
|
SELECT * FROM TQPMonitor
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|