jstuparitz (9/30/2008)
Just to provide a complete solution for everyone for George's suggestion see below. We've used this successfully and performance is excellent. For tables with binary/text columns you will need to change trigger a bit.Hope this helps. This will only work with Sql Server 2005 and above.
Thank you, thank you, thank you!
BTW what is [dbo].[AuditTable] for? Is not used anywhere.
For last in my case I got an error where the following SQL returned more than once the same column so I had to add the DISTINCT
SELECT @max-2=COUNT(DISTINCT c.[name])
FROM sys.all_columns c
INNER JOIN sys.all_objects o
ON c.object_id = o.object_id
INNER JOIN sys.types t
ON c.system_type_id = t.system_type_id
WHERE o.[name] = @TableName
AND o.[type] = 'U'