inserted/deleted tables on triggers

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Reaction score
13
I'm playing around with triggers and I want to know if there's way for me to get the table structure of inserted/deleted table?

Something like:

Code:
select c.name '@column', t.name '@type', c.max_length '@length' from sys.table_types as tt join sys.columns as c on tt.type_table_object_id = c.object_id join sys.types t on t.system_type_id = c.system_type_id and t.user_type_id = c.user_type_id and tt.type_table_object_id = c.object_id where tt.name = 'mytable' FOR XML PATH('table'), ROOT('table_structure')

Or is there a way for me to get the name of the table the trigger is firing on so I can do that anyway?
 
I think inserted/deleted tables are created when the trigger starts and then destroyed. So if you selecting #,#,# from XTable then that will be the structure of the inserted table.

I could be wrong but thsi seemed to be the case when i was creating triggers.
 
Cool thanks, I will google around some more. I basically want the trigger to push messages into my SOA layer for me, but I want it dynamic enough so even a n00b programmer can implement it.
 
Top
Sign up to the MyBroadband newsletter
X