Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dynamic variable declaration

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-02-13 : 08:08:27
Elsie B writes "Help - I'm new to SQL Server & my boss wants me to work wonders!

Is it possible to dynamically declare variables in T_SQL?

I need to write a generic trigger which can be applied to several tables, and so would like to dynamically declare the variables I need based on the fields I pull back from a query on syscolumns.

Also is it possible to return the name of the current parent table from a trigger - rather than have to change the table name every time the trigger is applied to a different table. I have tried several combinations of object.parent.name - with no success so far.

Thanks in advance."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-02-13 : 08:10:46
Frankly this is not a good approach, it's better (and easier) to write the triggers specifically for each table, rather than trying to create a cookie cutter approach that works for all of them.

Can you describe what your triggers are supposed to do?
Go to Top of Page
   

- Advertisement -