December 12, 2008 at 9:53 am
How can you tell from looking is sys.triggers which triggers are DDL?
Will it be under the type_Desc?
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
December 12, 2008 at 9:56 am
You can find your Database Triggers under progammability in the object explorer.
December 12, 2008 at 9:57 am
I fired the following query connected to AdventureWorks.....
Select * from sys.triggers
It displayed 'ddllogger' in the results.
When i fired the same query connected to Master
It returns nothing.
But whats the role of trigger 'ddllogger'?...and how does it impact the creation of view? I dont understand.
Regards
ItzSam
December 12, 2008 at 9:58 am
ok to see the definition, this works fine:
select object_definition(object_id) ,*
from sys.triggers
where parent_class=0
i see the type ="TR" And Type_desc = SQL_TRIGGER
Lowell
December 12, 2008 at 9:59 am
Christopher Stobbs (12/12/2008)
How can you tell from looking is sys.triggers which triggers are DDL?Will it be under the type_Desc?
The column parent_class_desc will say DATABASE for a DDL trigger.
December 12, 2008 at 10:01 am
I executed the following query....
"select object_definition(object_id) ,*
from sys.triggers
where parent_class=0"
and this is what it says about ddllogger.....
create trigger ddllogger on database for ddl_database_level_events as declare @xmldata xml set @xmldata = eventdata() insert ddlog values ( newid(), @xmldata.value('(/EVENT_INSTANCE/EventType)[1]','nvarchar(100)'), @xmldata.value('(/EVENT_INSTANCE/TSQLCommand)[1]','nvarchar(max)'), @xmldata.value('(/EVENT_INSTANCE/LoginName)[1]','nvarchar(100)'), getdate()) ddllogger5161968890DATABASE0TRSQL_TRIGGER2008-12-04 12:59:36.4372008-12-04 12:59:36.4370000
Regards
ItzSam
December 12, 2008 at 10:04 am
the issue is the audit table's definition;
can you
sp_help ddlog
one of the columns is too small for the desitnation data, causing the trigger to error and rollback, which prevents your view from being created.
Lowell
December 12, 2008 at 10:06 am
OK cool now I think you need to look at the columns in this table:
DDLog which is the table that this DDL trigger is inserting into 🙂
I must I am very glad you had this problem, cause I have just learn't so much over the last 30minutes it's amazing 🙂
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
December 12, 2008 at 10:11 am
I'm with Chris; I'm hitting refresh every 5 seconds to see what we find out next!
good learning day today!
Lowell
December 12, 2008 at 10:13 am
Most the teaching has been from you Lowell and Lynn 😉
Thanks
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
December 12, 2008 at 10:21 am
You can disable the database trigger with the following sql statement (change the name of the trigger, as this is the name of the DDL trigger in my version of AdventureWorks):
DISABLE TRIGGER [ddlDatabaseTriggerLog] ON DATABASE
You can reenable with the following:
ENABLE TRIGGER [ddlDatabaseTriggerLog] ON DATABASE
December 12, 2008 at 10:23 am
Sorry for the delayed reply....was away for sometime
when i executer sp_help ddlog
this is part of what it has to say.....
DDLEventIDuniqueidentifierno16 yes(n/a)(n/a)NULL
DDLEventnvarcharno200 yes(n/a)(n/a)Latin1_General_CI_AS
TSQLnvarcharno200 yes(n/a)(n/a)Latin1_General_CI_AS
EventUsernvarcharno200 yes(n/a)(n/a)Latin1_General_CI_AS
EventDatadatetimeno8 yes(n/a)(n/a)NULL
Regards
ItzSam
December 12, 2008 at 10:25 am
Looks like the TSQL column is too small you either need to do as Lynn said and disable the triggers or simply alter the table and extend the length of the TSQL field in the log table 🙂
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
December 12, 2008 at 10:27 am
Christopher Stobbs (12/12/2008)
Looks like the TSQL column is too small you either need to do as Lynn said and disable the triggers or simply alter the table and extend the length of the TSQL field in the log table 🙂
yep chris is right...see the definition for the third column, "TSQL" is varchar(200), but the trigger is passing varchar(max):
[font="Courier New"]CREATE TRIGGER ddllogger
ON DATABASE
FOR ddl_database_level_events
AS
DECLARE @xmldata XML
SET @xmldata = eventdata()
INSERT ddlog VALUES
(
NEWID(),
@xmldata.value('(/EVENT_INSTANCE/EventType)[1]','nvarchar(100)'),
@xmldata.value('(/EVENT_INSTANCE/TSQLCommand)[1]','nvarchar(max)'),
@xmldata.value('(/EVENT_INSTANCE/LoginName)[1]','nvarchar(100)'),
GETDATE()
) [/font]
Lowell
December 12, 2008 at 10:29 am
Yeah Chris....I agree with you.....
I cant disable the trigger as of now.....but can alter the table DDlog.
Even i learned a lot today from all you guys........really grateful to you.
Its just a simple concept of creation of view....but when you are not aware of the other objects that influence the creation, you start plucking your hair......:)
Thanks a Ton my friends.
Regards
ItzSam
Viewing 15 posts - 16 through 29 (of 29 total)
You must be logged in to reply to this topic. Login to reply