饿虎岗资源网 Design By www.oxmxm.com
复制代码 代码如下:
/******
对象: 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出来
饿虎岗资源网 Design By www.oxmxm.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
饿虎岗资源网 Design By www.oxmxm.com
暂无评论...
更新日志
2024年11月15日
2024年11月15日
- 群星《试音草原·女声篇》经典蒙古民歌[WAV+CUE][1G]
- 炉石传说月末上分卡组推荐 国服月末最快上分卡组推荐
- 炉石传说月底最强卡组有哪些 2024国服月底最强卡组推荐
- 炉石传说月初最强卡组有哪些 2024月初最强上分卡组推荐
- 狼人杀亮相原生鸿蒙之夜 假面科技强势登陆华为生态
- 12小时光线挑战!AI画质专家才是大平层首选
- 2024游戏IP报告:1~9月规模1960亿 68%用户愿为之付费
- 群星.2024-今夜一起为爱鼓掌电视剧原声带【相信音乐】【FLAC分轨】
- BIGFOUR.2013-大家利事【寰亚】【WAV+CUE】
- 李美凤.1992-情深透全情歌集【EMI百代】【WAV+CUE】
- 田震2024-《时光音乐会》[金峰][WAV+CUE]
- 群星《监听天碟3》[LECD]限量版[WAV+CUE]
- 心妤《声如夏花HQ》头版限量编号[WAV+CUE]
- 群星《摇滚五杰》[低速原抓WAV+CUE][1.1G]
- 群星 《2024好听新歌30》十倍音质 U盘音乐 [WAV+分轨]