cte formatting fails

torsten.strausstorsten.strauss Posts: 271 Silver 3
edited November 17, 2016 8:46AM in SQL Prompt
Hi !

The formatting on the following statement fails despite of the fact that parsing and executing is fine.


/*

Author: strat8
Create date: 2016-11-09
Revision History: yyyy-mm-dd Revisor
DescriptionOfChanges

Description: populate the ist.cvp_stage dimension

*/

SET NOCOUNT ON;
SET XACT_ABORT ON;

BEGIN TRY
BEGIN TRAN;

WITH cte
AS (
SELECT
ID_cvp_stage,cvp_stage
FROM
(
VALUES
( 1,'Appraise' )
, ( 2,'Select' )
, ( 3,'Define' )
, ( 4,'Execute' )
, ( 5,'Operate' )

)
AS cvp_stageTableName ( ID_cvp_stage, cvp_stage )
)

MERGE list.cvp_stage WITH ( SERIALIZABLE ) tar
USING cte sou
ON
tar.ID_cvp_stage = sou.ID_cvp_stage
WHEN NOT MATCHED BY TARGET THEN
INSERT
(
ID_cvp_stage, cvp_stage
)
VALUES (
sou.ID_cvp_stage
, sou.cvp_stage
) ;
COMMIT TRAN;
RETURN;
END TRY
BEGIN CATCH
@TRANCOUNT > 0
AND XACT_STATE() <> 0
ROLLBACK TRAN;
THROW;
END CATCH;

Comments

Sign In or Register to comment.