Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How can I rewrite for SQL Server a trigger that was originally written for Oracle ?

Here is my Oracle trigger code:

CREATE OR REPLACE TRIGGER P000KUL_TEST
BEFORE
INSERT
ON P000KUL
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
SELECT TO_CHAR(SYSDATE, 'dd/mm/RRRR') INTO :NEW.SYSTEM_DATE FROM DUAL;
SELECT TO_CHAR(SYSDATE, 'hh:mi') INTO :NEW.SYSTEM_TIME FROM DUAL;
END; 
share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

You can use trigger like this:

CREATE TRIGGER tr_P000KUL_INSERT
ON P000KUL
    FOR INSERT
    AS
    update inserted 
    set system_date = convert(varchar, getdate(), 103), 
        system_time = convert(varchar, getdate(), 108);
go
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.