Professional Documents
Culture Documents
Select Select From Where Order BY FOR XML Path From Group BY
Select Select From Where Order BY FOR XML Path From Group BY
WHERE
*
**
***
****
*****
******
*******
********
*********
WITH CTE
AS(
SELECT ID,Name,ManagerID, 1 RecursiveCallNumber FROM Employee WHERE ID=2
UNION ALL
SELECT E.ID,E.Name,E.ManagerID,RecursiveCallNumber+1 RecursiveCallNumber
FROM Employee E
INNER JOIN CTE ON E.ManagerID=CTE.ID)
SELECT * FROM CTE
Andrew
Smith 2
Richards
Jobs
empid EmpDup
Table
EmpId EmpDtl1
Table
EmpId EmpDtl2
Table
EmpName
EmpDtl1
Table
EmpName
EmpDtl2
Table
Now we have created a table and populated it with data. Next, we will run the following query to find out when it
was last updated.
BEGIN TRY
DECLARE @result INT
--Generate divide-by-zero error
SET @result = 55/0
END TRY
BEGIN CATCH
--Get the details of the error
--that invoked the CATCH block
DECLARE
@ErMessage NVARCHAR(2048),
@ErSeverity INT,
@ErState INT
SELECT
@ErMessage = ERROR_MESSAGE(),
@ErSeverity = ERROR_SEVERITY(),
@ErState = ERROR_STATE()
RAISERROR (@ErMessage,
@ErSeverity,
@ErState )
END CATCH