vendredi 3 juillet 2020

I need someone to test these T-SQL statements

Currently i'm unavailable to test these T-SQL statements because i'm on a trip and i don't have SQL Studio installed on my laptop, so if someone can test these statements i will be forever grateful, it's urgent!

USE master
CREATE DATABASE Workers

USE Workers
CREATE Table WorkerArrivals
(
    WorkerID INT IDENTITY(0,1) NOT NULL,
    WorkerTimeOfArrival TIME NOT NULL
)
ADD CONSTRAINTS WorkerArrivals_PK 
    PRIMARY KEY CLUSTERED
    (
        WorkerID
    )

USE Workers
GO
CREATE TRIGGER WorkerTimeOfArrival_Trigger
    ON WorkerArrivals
        INSTEAD OF INSERT
            AS
            BEGIN
                IF (SELECT CAST(CURRENT_TIMESTAMP AS TIME)) BETWEEN '20:00' AND '12:00'
                BEGIN
                    INSERT INTO WorkerArrivals
                    (
                        WorkerTimeOfArrival
                    )
                    SELECT CAST(CURRENT_TIMESTAMP AS TIME)
                END
                ELSE
                BEGIN
                    RAISERROR('ERROR: Table [WorkerArrivals] is avilable between 20:00 and 12:00', 10, 1)
                END
            END
END

If there are any errors executing this query, post it here. Thank you!

Aucun commentaire:

Enregistrer un commentaire