Sunday, February 14, 2010

CREATE FUNCTION

Which part of the following function definition will generate an error?

CREATE FUNCTION dbo.CreateContact(
@FirstName VARCHAR(50),
@LastName VARCHAR(50))
RETURNS INT
AS
BEGIN
DECLARE @ContactName VARCHAR(20)

SET @ContactName = LEFT(@FirstName, 1) + @LastName

INSERT INTO dbo.Contact(ContactName, FirstName, LastName )
VALUES (@ContactName, @FirstName, @LastName )

RETURN SCOPE_IDENTITY()
END


A. SET @ContactName = LEFT(@FirstName, 1) + @LastName
B. INSERT INTO dbo.Contact
C. RETURN SCOPE_IDENTITY()
D. No error is generated. The function will be created and compiled.

Answer:[B]
Highlight to find out the answer.

No comments:

Post a Comment