Click to See Complete Forum and Search --> : Trigger Doubt
shown_sunny
May 11th, 2004, 10:07 AM
dear friends,
Will u be able to tell me how do u get the current fieldname and current table name when performing an Trigger Update(SQL SERVER) on a particular table without specifying fieldname and tablename manually.
regards
shown_sunny
hspc
May 11th, 2004, 03:21 PM
I think this is not poosible..
I also wonder why can this useful for you ?
triggers are created on specific tables so know in advance table names..
also the tables (deleted/inserted) that are available in triggers can make code a bit reusable.;)
shown_sunny
May 12th, 2004, 03:46 AM
dear hspc,
Is it possible to give a common name replacing a table name like LOGIN and pass the arguments for the table names, so that just by passing the table name as argument for different table names , the same trigger can be applied for more than one table .
That means the same trigger can it be applied for more than one table.
for eg:
************************************
create trigger bis_upd on LOGIN FOR INSERT
************************************
can "LOGIN" be replaced by a common name like "tab_name"
and pass table names as arguments to this or by some other way.
*************************************************
I hope u have got the answer for the question regarding the TOP keyword i have posted.
************************************************
regards
shown sunny
:thumb:
hspc
May 12th, 2004, 04:44 AM
Originally posted by shown_sunny
for eg:
************************************
create trigger bis_upd on LOGIN FOR INSERT
************************************
can "LOGIN" be replaced by a common name like "tab_name"
and pass table names as arguments to this or by some other way.
No..this is not possible,,
I also think it's not a good thing..because SQL server can make triggers perform much better when it knows all tables/columns/queries in the trigger because it will make an execution plan that will be cached and used many times(the same applies to Stored procs,views etc)
Originally posted by shown_sunny
*************************************************
I hope u have got the answer for the question regarding the TOP keyword i have posted.
************************************************
:thumb:
I did not try it yet.. but i understood the idea .. good work :)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.