Your database stores telephone numbers. Each telephone number is stored as an integer. You must format the telephone number to print on a report in thefollowing format:(999) 999-9999You have selected the phone number into a local variable as follows:DECLARE @PhoneNumber int Which statement will correctly format the number?
A. SELECT 'Phone Number' = ‘(‘ + SUBSTRING(CONVERT(varchar(10),@PhoneNumber),3,0) + ‘)‘ + SUBSTRING(CONVERT(varchar(10), @PhoneNurnber),3,3)+‘-‘ + SUBSTRING(CONVERT(varchar(10), @PhoneNumber),4,6)
B. SELECT 'Phone Number' = ‘(‘ + SUBSTRING(CONVERT(varchar(10),@PhoneNuwber),3,1)+ ‘)‘ + SUBSTRING(CONVERT(varcher(10), @PhoneNumber),3,4)+ ‘-‘ +SUBSTRING(CONVERT(varchar(10), @PhoneMumber),4,7)
C. SELECT 'Phone Number' = ‘(‘ + SUBSTRING(CONVERT(varchar(10),@PhoneNumber),0,3) + ‘)‘ + SUBSTRING(CONVERT(varchar(10), @PhoneNumber),3,3)+‘-‘ + SUBSTRING(CONVERT(varchar(10), @PhoneNurtiber),6,4)
D. SELECT 'Phone Number' = ‘(‘ + SUBSTRING(CONVERT(varchar(10),@PhoneNumber),1,3) + ‘)‘ + SUBSTRING(CONVERT(varchar(10), @PhoneNumber),4,3)+'-' + SUBSTRING(CONVERT(varchar(10), @PhoneNumber),7,4)
You are a database developer for Wide World Importers. You are creating a database that will store order information. Orders will be entered in aclient/server application. Each time a new order is entered, a unique ordernumber must be assigned. Order numbers must be assigned in ascending order. Anaverage of 10,000 orders will be entered each day. You create a new table namedOrders and add an OrderNumber column to this table. What should you do next?
A. Set the data type of the column to UniqueIdentifier.
B. Set the data type of the column to int, and set the IDENTITYproperty for the column.
C. Set the data type of the column to int. Create a user-defined function that selects the maximum order number in the table.
D. Set the data type of the column to int. Create a NextKey table,and add a NextOrder column to the table. Set the data type of the NextOrdercolumn to int. Create a stored procedure to retrieve and update the value heldin the NextKey.
You are creating a script that will execute this stored procedure. Ifthe stored procedure executes successfully, it should report the year-to-datesales for the book title. If the stored procedure fails to execute, it shouldreport the following message:“No Sales Found”How should you create the script?
A. DECLARE @retval int DECLARE @ytd int EXEC get_sales_for_title ‘Net Etiquette’, @ytd IF @retval < 0 PRINT ‘No sales found’ ELSE PRINT ‘Year to date sales: ’ + STR (@ytd) GO
B. DECLARE @retval int DECLARE @ytd int EXEC get_sales_for_title ‘Net Etiquette’, @ytd OUTPUT IF @retval < 0 PRINT ‘No sales found’ ELSE PRINT ‘Year to date sales: ’ + STR (@ytd) GO
C. DECLARE @retval int DECLARE @ytd int EXEC get_sales_for_title ‘Net Etiquette’,@retvalOUTPUT IF @retval < 0 PRINT ‘No sales found’ ELSE PRINT ‘Year to date sales: ’ + STR (@ytd) GO
DECLARE @retval int DECLARE @ytd int EXEC @retval = get_sales_for_title ‘Net Etiquette’,@ytd OUTPUT IF @retval < 0 PRINT ‘No sales found’ ELSE PRINT ‘Year to date sales: ’ + STR (@ytd) GO
You area database developer for an insurance company. Information about the company'sinsurance policies is stored in a SQL Server 2000 database. You create a tablenamed policy for this database by using the script shown below:CREATE TABLE Policy(PolicyNumber int NOT NULL DEFAULT (0),InsuredLastName CHAR (30) NOT NULL,InsuredFirstName CHAR (20) NOT NULL,InsuredBirthDate dattime NOT NULL,PolicyDate datetime NOT NULL,FaceAmount money NOT NULL,CONSTRAINT PK_Policy PRIMARY KEY (PolicyNumber))Each time the company sells a new policy, the policy must be assigned a uniquepolicy number. The database must assign a new policy number when a new policyis entered. What should you do?
A. Create an INSTEAD OF INSERT trigger to generate a new policy number, and include the policy number in the data instead into the table.
B. Create an INSTEAD OF UPDATE trigger to generate a new policy number, and include the policy number in the data inserted into the table.
Create an AFTER UPDATE trigger to generate a new policy number, and include the policy number in the data inserted into the table.
D. Replace the DEFAULT constraint with a AFTER INSERT trigger that generates a new policy number and includes the policy number in the data inserted into the table.