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 If Update() in Trigger - Urgent!

Author  Topic 

tyaramis
Starting Member

3 Posts

Posted - 2005-06-29 : 03:37:23
Hi All

I have a question about generating dynmamicly If Update() statement in a trigger..

in My db, there is a table that holds some column names of an another table. for example;

Columns Table-A: Col1, Col2, Col3, Col4,Col5

Table-B: Col2, Col5 (The selected columns of Table A)

Then, in the Trigger of Table-A I use;

Select name from syscolumns where id=object_id('Table-A')

fetch next from TableA_Cursor into @strColName

then, I used a statement like this..

if UPDATE(' + @strColName + ')

But it gives "incorrect syntax" error..

How can I write this line?

Thanks alot in advance...

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-06-29 : 14:26:31
No you can not do this dynamically nor would it be advised due to the slowness of the cursor. Your trigger needs to be as fast as possible so that the transction can complete quickly so as not to impact other users accessing that table.

Tara
Go to Top of Page
   

- Advertisement -