Which Transact-SQL statement should you use?

You administer a database that includes a table named Customers that contains more than 750 rows. You
create a new column named PartitionNumber of the int type in the table. You need to assign a PartitionNumber
for each record in the Customers table. You also need to ensure that the PartitionNumber satisfies thefollowing
conditions:
Always starts with 1.
Starts again from 1 after it reaches 100.
Which Transact-SQL statement should you use?

You administer a database that includes a table named Customers that contains more than 750 rows. You
create a new column named PartitionNumber of the int type in the table. You need to assign a PartitionNumber
for each record in the Customers table. You also need to ensure that the PartitionNumber satisfies thefollowing
conditions:
Always starts with 1.
Starts again from 1 after it reaches 100.
Which Transact-SQL statement should you use?

A.
CREATE SEQUENCE CustomerSequence AS int
START WITH 0
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100
UPDATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
DROP SEQUENCE CustomerSequence

B.
CREATE SEQUENCE CustomerSequence AS int
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100
CYCLE
UPDATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
DROP SEQUENCE CustomerSequence

C.
CREATE SEQUENCE CustomerSequence AS int
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100
UPDATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence + 1
DROP SEQUENCE CustomerSequence

D.
CREATE SEQUENCE CustomerSequence AS int
START WITH 1
INCREMENT BY 1
MINVALUE 0
MAXVALUE 100
CYCLE
UPTATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
DROP SEQUENCE CustomerSequence

Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ff878091.aspx



Leave a Reply 2

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