2
在SQL Server 2008中獲取表名,我有一個DDL觸發器,漸漸被以下觸發創建的表的表名:SQL Azure的:在CREATE TABLE TRIGGER
CREATE TRIGGER [tr_getName] ON DATABASE FOR CREATE_TABLE
AS
DECLARE @xmlEventData XML
DECLARE @TableName varchar(128)
-- Capture the event data that is created
SET @xmlEventData = eventdata()
IF OBJECT_ID('dbo.tNames', 'U') IS NOT NULL
BEGIN
DeAllocate tNames
END
DECLARE tNames CURSOR Read_Only
FOR SELECT CONVERT(VARCHAR(128), @xmlEventData.query('data(/EVENT_INSTANCE/ObjectName)'))
OPEN tNames
FETCH Next FROM tNames
INTO @TableName
...
...
然而,在SQL Azure eventdata()不再受支持。有沒有辦法在SQL Azure中實現相同的功能? 謝謝