Seleziona l'iniziale:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
> Clicca qui per scaricare l'elenco completo delle domande di questo argomento in formato Word!
Use vertical partitioning to turn off replication for that article.
Choose 3. SELECT au_fname as ‘Name’ FROM Authors
Choose 3. SELECT ‘Name’ = au_fname FROM Authors
Choose 3. SELECT au_fname ‘NAME’ FROM Authors
Choose all that apply. WHERE name = ‘Bobby’ or name = ‘Bobbi’
Choose all that apply. WHERE name LIKE ‘Bobb[iy]’
The leaf pages of the index are the data pages of the table.
It contains multiple columns in its key.
CREATE TABLE News ( NewsID int NOT NULL, NewsText varchar (8000) NOT NULL, EmployeePositionType char (15) NOT NULL, DisplayUntil datetime NOT NULL, DateAdded datetime NOT NULL DEFAULT (getdate( )), CONSTRAINT PK_News PRIMARY KEY (NewsID) )
Users of the intranet need to view data in the news table, but do not need to insert, update, or delete data in the table. You need to deliver only the appropriate data to the intranet, based on the employee's position type. What should you do? Create a stored procedure that returns the rows that apply to a specified position type.
Table1:
UserID int IDENTITY
FirstName char(50)
LastName char(50)
DepartmentID int
BillingID int
CREATE TRIGGER Table1_InsertUpdate
ON Table1
FOR INSERT, UPDATE
AS
BEGIN
IF UPDATE(DepartmentID)
IF (Select count(*) from Table1 inner join Deleted on Table1.DepartmentID = deleted.departmentid) = 0
BEGIN
RAISERROR ('Cannot remove the last member from a department.', 16, 1)
ROLLBACK
END
END
What does the ROLLBACK statement in the trigger do?
It causes the transaction containing the offending statement to roll back.
Table1:
UserID int IDENTITY
FirstName char(50)
LastName char(50)
DepartmentID int
BillingID int
CREATE TRIGGER Table1_InsertUpdate
ON Table1
FOR INSERT, UPDATE
AS
BEGIN
IF UPDATE(DepartmentID)
IF (Select count(*) from Table1 inner join Deleted on Table1.DepartmentID = deleted.departmentid) = 0
BEGIN
RAISERROR ('Cannot remove the last member from a department.', 16, 1)
ROLLBACK
END
END
What does the RAISERROR statement in the trigger do?
It provides the connection with an error message.
Table1:
UserID int IDENTITY
FirstName char(50)
LastName char(50)
DepartmentID int
BillingID int
CREATE TRIGGER Table1_InsertUpdate
ON Table1
FOR INSERT, UPDATE
AS
BEGIN
IF UPDATE(DepartmentID)
IF (Select count(*) from Table1 inner join Deleted on Table1.DepartmentID = deleted.departmentid) = 0
BEGIN
RAISERROR ('Cannot remove the last member from a department.', 16, 1)
ROLLBACK
END
END
Assuming that this is the only trigger bound to the table, is it possible for the last member of a department to be deleted?
Yes, by using the DELETE command.
Table1:
UserID int IDENTITY
FirstName char(50)
LastName char(50)
DepartmentID int
BillingID int
CREATE TRIGGER Table1_InsertUpdate
ON Table1
FOR INSERT, UPDATE
AS
BEGIN
IF UPDATE(DepartmentID)
IF (Select count(*) from Table1 inner join Deleted on Table1.DepartmentID = deleted.departmentid) = 0
BEGIN
RAISERROR ('Cannot remove the last member from a department.', 16, 1)
ROLLBACK
END
END
Assuming that nested trigger is turned on, how could this trigger be modified to set the BillingID to 1 if the department is successfully changed?
Adding an ELSE clause to the IF SELECT statement makes the appropriate update.