How can we help you today? How can we help you today?

"Sequence Contains No Elements" when formatting a MERGE

When I try to format any SQL query containing a MERGE statement using SQL Prompt 7.3.0.418, I get a popup error stating that "SQL Prompt was unable to complete this operation. Problem areas have been highlighted."

The first character in the query is then shown with red underlining, and the tooltip reads "Sequence contains no elements".

The following code is the MCVE to reproduce:
DECLARE @Table TABLE (x INT,y DATE)

	MERGE @Table AS Target 
	USING 
	  (
		SELECT 1 AS x, '2016-08-18' AS y
		) AS Source
		ON Target.x = Source.x

	WHEN MATCHED 
		AND Target.y != Source.y
	THEN UPDATE 
		SET
			Target.y = Source.y

	WHEN NOT MATCHED BY Target
	THEN INSERT
		 (x,y)
		VALUES (Source.x, Source.y)

	WHEN NOT MATCHED BY Source 
	THEN UPDATE 
		SET Target.y = '1700-01-01'


SELECT * FROM @Table t
a.higgins
0

Comments

3 comments

  • Aaron L
    Hi a.higgins,

    Thanks for letting us know about this - we can reproduce this here and will look into a fix (hopefully it'll be in a new build tomorrow)

    Thanks!
    Aaron.
    Aaron L
    0
  • Aaron L
    Hi a.higgins,

    We've just released a new beta build which should have a fix for this if you'd like to give it a try?

    Thanks,
    Aaron.
    Aaron L
    0
  • a.higgins
    Confirmed, Aaron, the latest beta version allows me to format MERGE statements.
    a.higgins
    0

Add comment

Please sign in to leave a comment.