Which Transact-SQL statement should you use?

You are responsible for a SQL Server database. You require the tables to be added or altered only on the first day of the month. You need to ensure that if the tables are attempted to be modified or created on any other day, an error is received and the attempt is not successful.
Which Transact-SQL statement should you use?

You are responsible for a SQL Server database. You require the tables to be added or altered only on the first day of the month. You need to ensure that if the tables are attempted to be modified or created on any other day, an error is received and the attempt is not successful.
Which Transact-SQL statement should you use?

A.
CREATE TRIGGER TRG_TABLES_ON_FIRST
ON DATABASE FOR CREATE_TABLE
AS
IF DATEPART(day,getdate())>1
BEGIN
RAISERROR (‘Must wait til next month.’, 16, 1)
END

B.
CREATE TRIGGER TRG_TABLES_ON_FIRST ON DATABASE FOR CREATE_TABLE,ALTER_TABLE AS
IF DATEPART(day,getdate())>1
BEGIN
RAISERROR (‘Must wait til next month.’, 16, 1)
END

C.
CREATE TRIGGER TRG_TABLES_ON_FIRST ON DATABASE FOR CREATE_TABLE,ALTER_TABLE AS
IF DATEPART(day,getdate())>1
BEGIN
ROLLBACK
RAISERROR (‘Must wait til next month.’, 16, 1)
END

D.
CREATE TRIGGER TRG_TABLES_ON_FIRST ON ALL SERVER FOR ALTER_DATABASE AS
IF DATEPART(day,getdate())>1
BEGIN
ROLLBACK
RAISERROR (‘Must wait til next month.’, 16, 1)
END



Leave a Reply 0

Your email address will not be published. Required fields are marked *