标签:files logs .sql res 地方 microsoft 语句 primary rtu
SELECT * FROM [sys].[dm_db_index_physical_stats](NULL, NULL, NULL, NULL, NULL); GO SELECT * FROM [sys].[dm_db_index_physical_stats](DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT); GO
DECLARE @nvcDefaultTraceFilePath AS NVARCHAR(4000); SET @nvcDefaultTraceFilePath = N‘‘; SELECT @nvcDefaultTraceFilePath = [path] FROM [sys].[traces] WHERE [id] = 1; SELECT * FROM ::fn_trace_gettable(@nvcDefaultTraceFilePath, NULL); SELECT * FROM ::fn_trace_gettable(@nvcDefaultTraceFilePath, DEFAULT); GO
SELECT * FROM ::fn_virtualfilestats(1, NULL); SELECT * FROM ::fn_virtualfilestats(1, DEFAULT);
USE [tempdb]; GO -- 创建队列 IF OBJECT_ID(N‘[dbo].[NotifyQueue]‘, ‘SQ‘) IS NULL BEGIN CREATE QUEUE [dbo].[NotifyQueue] WITH STATUS = ON ,RETENTION = OFF END GO -- 创建服务 IF NOT EXISTS (SELECT 1 FROM [sys].[services] WHERE [name] = N‘EventNotifyService‘) BEGIN CREATE SERVICE [EventNotifyService] ON QUEUE [dbo].[NotifyQueue] ([http://schemas.microsoft.com/SQL/Notifications/PostEventNotification]); END GO -- 创建路由 IF NOT EXISTS (SELECT 1 FROM [sys].[routes] WHERE [name] = N‘NotifyRoute‘) BEGIN CREATE ROUTE [NotifyRoute] WITH SERVICE_NAME = N‘EventNotifyService‘ ,ADDRESS = N‘LOCAL‘; END GO -- 创建事件通知 IF NOT EXISTS (SELECT 1 FROM [sys].[event_notifications] WHERE [name] = N‘CreateTableNotification‘) BEGIN CREATE EVENT NOTIFICATION [CreateTableNotification] ON DATABASE FOR CREATE_TABLE TO SERVICE ‘EventNotifyService‘, ‘current database‘; END GO
IF OBJECT_ID(N‘[dbo].[TableCreate]‘, ‘U‘) IS NULL BEGIN CREATE TABLE [dbo].TableCreate ( Col1 INT ,Col2 VARCHAR(100) ,Col3 XML ) ON [PRIMARY] END GO
SELECT CAST([message_body] AS XML) ,message_enqueue_time ,* FROM [dbo].NotifyQueue GO
标签:files logs .sql res 地方 microsoft 语句 primary rtu
原文地址:http://www.cnblogs.com/dzy863/p/6389469.html