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
 General SQL Server Forums
 New to SQL Server Programming
 Syntax Trigger Help

Author  Topic 

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2008-01-30 : 16:48:35
This Continues a question from previous trigger advice question

Is there no global way to grab all columns for a row
I tried using * like you would with select. But it failed.
I have been unable to find an example or command that shows
if this possible. The all show you have to type out your
fields and in my case that would take time. The below
does not work. Does anyone have a advice on this, Thanx.

INSERT INTO Archive ()
Select i.*


This section of the trigger does work.
SET IDENTITY_INSERT Archive ON
INSERT INTO Archive (grid, name, address, state, zip, arc)
SELECT i.grid, i.name, i.address, i.state, i.zip, i.arc
from Inserted i
inner join deleted d
on d.grid = i.grid
inner join [Active] a
on a.grid = i.grid
WHERE i.arc = 1
and isNull(d.arc,0) != 1

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-01-30 : 17:33:56
You should not use "*" in production code. If you want to avoid typing you can generate the columns with this:

select char(9) + ',' + column_name from information_schema.columns where table_name = 'archive' order by ordinal_position

Just to correct your syntax, you would leave of the empty "()" for the columnlist when using "SELECT *".

Be One with the Optimizer
TG
Go to Top of Page

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2008-01-30 : 17:38:50
I understand, Thank you...
Go to Top of Page
   

- Advertisement -