|
I have created a trigger to returns the affected column names.[Trg_MyMaster] But Its not returning the last column name if I update the last column (Table Name is MyMaster]. But MyTest table is created from MyMaster and created the same Trigger. [Trg_MyTest] returns the last column name correctly if I update the last column in MyTest table. records and table structure are same between both table. Create TRIGGER [Trg_MyTest] ON [dbo].[MyTest] FOR UPDATE AS Begin Print COLUMNS_UPDATED() Set @TableName='MyTest' End
(comments are locked)
|
|
if you are running on SQL Server 2008 then MSDN COLUMNS_UPDATED (Transact-SQL) says:
Your trigger can be much more easier. On SQL Server you need to use column_id Thanks for this Pavel. But It returns the column names incorrectly... changes need in WHERE condition?
Jul 28 '11 at 06:57 AM
karthik
I tested this on a test table I've created and it returned the columns correct. Only they are comma separated. Or you what you mean by incorrectly?
Jul 28 '11 at 07:03 AM
Pavel Pawlowski
Yes.For Test table, I am also getting the column names correctly. But I added this piece of code to main tables trigger its not returning the correct column names.
Jul 28 '11 at 07:40 AM
karthik
In the trigger is hard coded
Jul 28 '11 at 08:14 AM
Pavel Pawlowski
yes.. please see the below code i added
Jul 28 '11 at 08:47 AM
karthik
(comments are locked)
|

