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.
Author |
Topic |
simondeutsch
Aged Yak Warrior
547 Posts |
Posted - 2012-04-18 : 13:34:49
|
I'm trying to do an INSERT trigger on a table, where if a row that has a code of e.g. A gets inserted, another row should get inserted with the exact same information except the code should be B. I'd like to avoid having to use column names like INSERT Table (Code, Column1,Column2) SELECT 'B',Column1, Column2 FROM Inserted because the table structure can change and then the trigger will break. So how can it do INSERT TableMC SELECT *, except the code column value should be different?CREATE TRIGGER trgCodeMC ON dbo.TableMC FOR INSERT ASIF EXISTS(SELECT * FROM Inserted WHERE Code = 'MC')BEGIN --INSERT statement hereEND |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-04-19 : 04:33:50
|
Insert the same information to another table and update that column to 'B' if you want to avoid listing columnsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|