You use Microsoft SQL Server 2012 to develop a database application. You create two tables by using the
following table definitions.
Which six Transact-SQL statements should you use? (To answer, move the appropriate SQL statements from
the list of statements to the answer area and arrange them in the correct order.)

Answer:
Hi. Anyone know right answer?
0
0
1, 8, 2, 6, 3, 5
This is hard one…
0
0
Merge CountryRegion as target
Using(select @CountryRegionCode,@Name) as source(CountrtRegionCode,Name)
On (target.CountrtRegionCode=source.CountrtRegionCode)
When not matched by target then
Insert into CountryRegion
(CountrtRegionCode,Name)
Values(@CountryRegionCode,@Name)
When matched then update set name=source.Name
0
0
The answer is correct
CREATE FUNCTION [dbo].[getsubtree](@empid AS INT)
RETURNS @Tree TABLE(empid INT NOT NULL,
empname VARCHAR(25) NOT NULL,
mgrid INT NOT NULL,
M INT NOT NULL)
AS
BEGIN
WITH Employees_Subtree(empid,empname,mgrid,M)
AS
(SELECT empid,empname,mgrid,0
FROM Employees WHERE empid=@empid
UNION ALL
SELECT e.empid,e.empname,e.mgrid,es.M+1
FROM Employees AS e JOIN Employees_Subtree AS es ON e.mgrid=es.empid
)
INSERT INTO @Tree
SELECT * FROM Employees_Subtree
RETURN
END
GO
0
0