Hi, I'm creating a trigger to be deployed on a couple of hundred tables to audit insert, Update and delete. You cannot have after if some fields are text, so how can I convert to varchar on the select? See the statement below. I just need the convert part for the statement.
Create TRIGGER [dbo].[tri_pfAudit_@tblName_INSERT] ON [dbo].[@tblName]
Declare @x as XML
--In select I need to check if text, and convert to varchar
Select @x = (Select * from Inserted FOR XML AUTO, BINARY BASE64 , ELEMENTS, Root(''ROOT''))
Insert Table_Audit(TableName,txtXML,Action) Select ''@tblName'',@x,''I''