复制代码 代码如下:
/******
对象: DdlTrigger [Trig_DBVersionController]
脚本日期: 09/05/2008 15:50:16
作用: 数据库版本控制
******/
IF EXISTS (SELECT * FROM sys.triggers WHERE name = N'Trig_DBVersionController' AND parent_class=0)
DROP TRIGGER [Trig_DBVersionController] ON DATABASE
GO
CREATE TRIGGER [Trig_DBVersionController]
ON DATABASE
FOR CREATE_TABLE, ALTER_TABLE, DROP_TABLE,
CREATE_FUNCTION, ALTER_FUNCTION, DROP_FUNCTION,
CREATE_INDEX, ALTER_INDEX, DROP_INDEX,
CREATE_PROCEDURE, ALTER_PROCEDURE, DROP_PROCEDURE,
CREATE_TRIGGER, ALTER_TRIGGER, DROP_TRIGGER,
CREATE_VIEW, ALTER_VIEW, DROP_VIEW
AS
SET NOCOUNT ON
DECLARE @data AS xml
DECLARE @clientUser AS nvarchar(128)
DECLARE @spid AS nvarchar(128)
DECLARE @serverName AS nvarchar(128)
DECLARE @dbName AS nvarchar(128)
DECLARE @dbid AS int
DECLARE @objName AS nvarchar(512)
SELECT @data =EVENTDATA()
SELECT @spid = @data.value('(/EVENT_INSTANCE/SPID)[1]','nvarchar(128)')
SELECT @serverName = @data.value('(/EVENT_INSTANCE/ServerName)[1]','nvarchar(256)')
SELECT @dbName = @data.value('(/EVENT_INSTANCE/DatabaseName)[1]','nvarchar(128)')
SELECT @objName = @data.value('(/EVENT_INSTANCE/ObjectName)[1]','nvarchar(128)')
SELECT @dbid = dbid FROM sys.sysdatabases
WHERE name = @dbName
--获取客户机的机器名
SELECT @clientUser=hostname FROM master..sysprocesses WHERE spid=@spid
-- add version record
INSERT INTO DBController.dbo.tbl_version_details
(post_computer_name, sys_dbid, uid, [schema],
PostTime, EventType, ObjectType, ObjectName, CommandText, Remark)
VALUES
(@clientUser, @dbid,
@data.value('(/EVENT_INSTANCE/LoginName)[1]','nvarchar(256)'),
@data.value('(/EVENT_INSTANCE/UserName)[1]','nvarchar(256)'),
@data.value('(/EVENT_INSTANCE/PostTime)[1]','datetime'),
@data.value('(/EVENT_INSTANCE/EventType)[1]','nvarchar(128)'),
@data.value('(/EVENT_INSTANCE/ObjectType)[1]','nvarchar(128)'),
@objName,
@data.value('(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]','nvarchar(max)'),
''
)
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ENABLE TRIGGER [Trig_DBVersionController] ON DATABASE
GO
上面是trigger
下面是存储的库和表结构
提供图片
上面图片可以清淅看到表结构
大家写出表的SQL出来
/******
对象: DdlTrigger [Trig_DBVersionController]
脚本日期: 09/05/2008 15:50:16
作用: 数据库版本控制
******/
IF EXISTS (SELECT * FROM sys.triggers WHERE name = N'Trig_DBVersionController' AND parent_class=0)
DROP TRIGGER [Trig_DBVersionController] ON DATABASE
GO
CREATE TRIGGER [Trig_DBVersionController]
ON DATABASE
FOR CREATE_TABLE, ALTER_TABLE, DROP_TABLE,
CREATE_FUNCTION, ALTER_FUNCTION, DROP_FUNCTION,
CREATE_INDEX, ALTER_INDEX, DROP_INDEX,
CREATE_PROCEDURE, ALTER_PROCEDURE, DROP_PROCEDURE,
CREATE_TRIGGER, ALTER_TRIGGER, DROP_TRIGGER,
CREATE_VIEW, ALTER_VIEW, DROP_VIEW
AS
SET NOCOUNT ON
DECLARE @data AS xml
DECLARE @clientUser AS nvarchar(128)
DECLARE @spid AS nvarchar(128)
DECLARE @serverName AS nvarchar(128)
DECLARE @dbName AS nvarchar(128)
DECLARE @dbid AS int
DECLARE @objName AS nvarchar(512)
SELECT @data =EVENTDATA()
SELECT @spid = @data.value('(/EVENT_INSTANCE/SPID)[1]','nvarchar(128)')
SELECT @serverName = @data.value('(/EVENT_INSTANCE/ServerName)[1]','nvarchar(256)')
SELECT @dbName = @data.value('(/EVENT_INSTANCE/DatabaseName)[1]','nvarchar(128)')
SELECT @objName = @data.value('(/EVENT_INSTANCE/ObjectName)[1]','nvarchar(128)')
SELECT @dbid = dbid FROM sys.sysdatabases
WHERE name = @dbName
--获取客户机的机器名
SELECT @clientUser=hostname FROM master..sysprocesses WHERE spid=@spid
-- add version record
INSERT INTO DBController.dbo.tbl_version_details
(post_computer_name, sys_dbid, uid, [schema],
PostTime, EventType, ObjectType, ObjectName, CommandText, Remark)
VALUES
(@clientUser, @dbid,
@data.value('(/EVENT_INSTANCE/LoginName)[1]','nvarchar(256)'),
@data.value('(/EVENT_INSTANCE/UserName)[1]','nvarchar(256)'),
@data.value('(/EVENT_INSTANCE/PostTime)[1]','datetime'),
@data.value('(/EVENT_INSTANCE/EventType)[1]','nvarchar(128)'),
@data.value('(/EVENT_INSTANCE/ObjectType)[1]','nvarchar(128)'),
@objName,
@data.value('(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]','nvarchar(max)'),
''
)
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ENABLE TRIGGER [Trig_DBVersionController] ON DATABASE
GO
上面是trigger
下面是存储的库和表结构
提供图片
上面图片可以清淅看到表结构
大家写出表的SQL出来
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
更新日志
2024年11月22日
2024年11月22日
- 刘德华《LOVEHOPE 希望 爱》香港首批豪华版[WAV+CUE][1.1G]
- 群星.1994-宝丽金超级孖宝2CD【宝丽金】【WAV+CUE】
- 群星.1992-滚石第一流台湾歌·12王牌大车拼【滚石】【WAV+CUE】
- 龚玥《金装龚玥HQCD》头版限量[WAV+CUE]
- 任贤齐《任贤齐创作集 音乐旅行者》[WAV+CUE][1.1G]
- 群星《快乐巨星·百万畅销曲85》2CD[WAV+CUE][828M]
- 合集《IU 李知恩2009-2022所有歌曲合集》[FLAC][7.4G]
- 童丽-《民歌》紫银合金AQCD[WAV+CUE]
- 刀郎2024.08.30《山歌响起的地方》资中“知交”线上演唱会.mp4
- [爵士女声测试大碟]洁辛塔《秋叶)[SACD-WAV]
- 任贤齐《任贤齐创作集 音乐旅行者》[WAV+CUE][1.1G]
- 赵传《一颗滚石的25年》 2CD引进版[WAV+CUE][1.6G]
- 群星《往岁乘霄》[320K/MP3][39.84MB]
- 群星《往岁乘霄》[FLAC/分轨][211.79MB]
- 群星.2024-JamboMedley(BEYOND40周年致敬2)【Kinns】【FLAC分轨】