Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trigger question
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01500199
Message ID:
01500223
Views:
38
>>Hello all, first things first - I have never used triggers. In a lot of my sp's I create a record of the current values of a table that I'm about to update along with the new values for the table - this makes it very easy for me to report on edits, is it possible to do this using a trigger ? A typical example of what I do is shown below
>>
>>
>>Proc UpdateAddress(@Addressid int,@line1 varchar(35),(@line2 varchar(35),
>>(@line3varchar(35),
>>(@line4 varchar(35))
>>As
>>Insert into AddressHistory
>>(Addressid int,
>>line1 ,
>>line2,
>>line3,
>>line4,
>>xline1,
>>xline2,
>>xline3,
>>xline4)
>>(Select
>>Addressid,
>>line1,
>>line2,
>>line3,
>>line4,
>>@line1,
>>@line2,
>>@line3,
>>@line4 from address where addressid = @Addressid  )
>>
>>-- Then update the address table with new values
>>
>>
>>
>>
>
>Sure, although you can also do the same using OUTPUT clause of Update command in your SP that updates the Address table. Triggers should be used as a last resort.

Oh, wasn't aware of OUTPUT clause - will check it out - thanks
Regards,
Peter J. Kane



Pete
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform