You work as a database developer at ABC.com. ABC.com has a SQL Server 2012 database
infrastructure with a very large database named SalesDB. You create a new table named
SalesHistory that will hold historical data from the SalesDB database.
You need to perform a batch update from the SalesDB database to the SalesHistory table. You
want the status information from the batch process to be logged to a SQL Server table that must
be created by the batch process.
How would you accomplish this task?
A.
You should make use of the FORMAT function.
B.
You should make use of the CONVERT function.
C.
You should make use of a scalar user-defined function.
D.
You should make use of an inline function.
E.
You should make use of a table-valued function.
F.
You should make use of a stored procedure.
Explanation:
isn’t F ?!
For sure F.
for me is E. Stored procedures only create tables using dynamic queries that are very difficult to manage when the table gets complex. here is an example of the creation of a table on a TVF
CREATE FUNCTION dbo.ufnGetContactInformation(@ContactID int)
RETURNS @retContactInformation TABLE
(
— Columns returned by the function
ContactID int PRIMARY KEY NOT NULL,
FirstName nvarchar(50) NULL,
LastName nvarchar(50) NULL,
JobTitle nvarchar(50) NULL,
ContactType nvarchar(50) NULL
)
AS
using TVF you can create the sql table to store the status information and update SalesHistory
F is correct.
You can make executing the batch process one of the steps in the stored procedure.
A requirement is that the status of the batch must be logged to “a SQL Server table that must be created by the batch process” – functions cannot create tables but stored procedures can.
?
F