Saturday, February 25, 2012

Magic Tables with Text Columns

Hi folks,

I need to execute some kind of

select a,b,c into #inserted from inserted

a = int
b = varchar(50)
c = text

Easy so far. But I what I need is to find out whether the audited table contains text(or nText / image) columns or not. If it contains any text columns the statement should automatically be changed to

select a,b into #inserted from inserted

Remember that the trigger must be usable for any table in the database without manually entering the tables structure or the column names.

Best would be fetching the structure fropm the system views (INFORMATIONSCHEMES)

Any suggestions ?

Thanks a lot!

StefanTRIGGERS are built for a table, and as such are a "property" of that table.

The only way would be to build dynamic sql with each trigger for each table.

Meaning you would still have to build a trigger per table anyway.

So why not just build them the way they need to be per table?

And what's with the temp table?

No comments:

Post a Comment