I am trying to create a SQL Trigger in SQL Server that will somehow serialize the Inserted and Deleted tables for use in .NET code (via sp_oamethod). I would like this to be generic enough to use for any table.
My first attempt involved using "for xml" to serialize it into XML, and pass it to .NET code. However, I have been unable to assign the XML to a variable, as it is not supported in SQL Server 2000 (2005 is not yet an option for us). The only option is to do the serialization manually (Ref. http://stackoverflow.com/questions/914009/saving-the-for-xml-auto-results-to-variable-in-sql) and that does not fit my requirements of being generic.
--This does not work
declare @OldValue varchar(5000)
select @OldValue = (select * from Deleted for XML auto)
Does anyone know of a way to do this generically, using any method? I do not care about the format, as long as I can get the column names and values into my .NET code.