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 |
|
lakshmireddym
Starting Member
6 Posts |
Posted - 2006-06-30 : 07:58:43
|
| Hi,I have a trigger in mysql as below...I need to change it into sqlserver.I am unable to find replacement to 'for each row'.Can u please let me know how can we change this trigger into sqlserver format.CREATE TRIGGER TGR_ENTITY_TYPE_ON_ADD BEFORE INSERT ON ENTITY_TYPEFOR EACH ROW SET NEW.DATE_ADDED=NOW(), NEW.DATE_MODIFIED=NOW();Thanks in advance,MLR |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-06-30 : 08:20:31
|
You have to have a column that identifies each row.The DATE_ADDED columns doesn't need toUPDATE ENTITY_TYPESET DATE_ADDED = GETDATE()WHERE DATE_ADDED IS NULL For DATE_MODIFIED you can use something like thisUPDATE ENTITY_TYPESET DATE_ADDED = GETDATE()WHERE UniqueCol IN (SELECT UniqueCol FROM inserted) Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-30 : 08:48:46
|
quote: CREATE TRIGGER TGR_ENTITY_TYPE_ON_ADD BEFORE INSERT ON ENTITY_TYPEFOR EACH ROW SET NEW.DATE_ADDED=NOW(),NEW.DATE_MODIFIED=NOW();
Where did you find such code?Read about Triggers in sql server help file for proper systaxMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|