"Failed to update" message after encountering a ";" in a stored procedure
Ran into an issue when entering a stored procedure with a semi colon in it.
Failed to update:
oEc.#8Jf: Errors occured whilst parsing file C:\Documents and Settings\Adam\Local Settings\Application Data\Red Gate\SQL Source Control 0\WorkingBases\4c857d86-7cf5-464b-86bc-01d4f22d1423\Stored Procedures\Article.GetArticlesByKewords.sql
'line 47:2: unexpected token: [";",<631>,line=47,col=2] [char=1276]'
---> cZ: Errors occured whilst parsing file C:\Documents and Settings\Adam\Local Settings\Application Data\Red Gate\SQL Source Control 0\WorkingBases\4c857d86-7cf5-464b-86bc-01d4f22d1423\Stored Procedures\Article.GetArticlesByKewords.sql
'line 47:2: unexpected token: [";",<631>,line=47,col=2] [char=1276]'
---> line 47:2: unexpected token: [";",<631>,line=47,col=2] [char=1276]
--- End of inner exception stack trace ---
at #oEc.#7Jf.#t.#B3.#sKf()
at #oEc.#7Jf.#gKf(Action action)
--- End of inner exception stack trace ---
Server stack trace:
at #eEc.#fEc.#t.#izb.#j5f()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
Exception rethrown at [0]:
at RedGate.SQLSourceControl.CommonUI.Forms.ErrorDialog.DoWithObviousExceptionsThrowAll(Action action)
at #JLc.#PLc.#CTc(ICancellableOperation`1 operation, Object token)
For your information, the following is the text in the stored procedure....
-- =============================================
-- Author: <Chandrashekar>
-- Create date: <10 Jun 2009>
-- Description: <Get Articles By Kewords and Section >
-- =============================================
CREATE Procedure [Article].[GetArticlesByKewords]
(
@Keywords varchar(max) = '',
@Section varchar(50) = Null,
@ArticleId int = Null, --For Suppressing Articles
@CountID int = Null,
@IncludeDeleted bit = 0
)
As
/*
SELECT
distinct c.contentid as contentid,
c.titlebox1 as title,
c.section as section,
c.keywords as keyword,
c.priority as priority,
article.section.SectionName as description
FROM
content c
CROSS APPLY dbo.Csvtovarchar(@Keywords) r
INNER JOIN content On c.keywords LIKE '%' + r.VarCharValue + '%'
INNER JOIN article.section ON article.section.SectionCode =c. section-- @Section
WHERE c.contenttype='ARTICLE'
AND
(
(@Section IS NULL )OR
(@Section IS NOT NULL AND c.section LIKE '%' + @Section + '%' )
)
AND
(
(@ArticleId IS NULL )OR
(@ArticleId IS NOT NULL AND c.contentid <> @ArticleId )
) */
;
With cte (rank,contentid,title,section,keyword,priority,description)
As (
SELECT
--row_number() Over(Order by c.priority),
rank() Over(Order by c.contentid ),
c.contentid as contentid,
c.titlebox1 as title,
c.section as section,
c.keywords as keyword,
c.priority as priority,
article.section.SectionName as description
FROM
content c
CROSS APPLY dbo.Csvtovarchar(@Keywords) r
--INNER JOIN content On c.keywords LIKE '%' + r.VarCharValue + '%'
INNER JOIN article.section ON article.section.SectionCode = c. section-- @Section
WHERE c.contenttype='ARTICLE'
And c.keywords LIKE '%' + r.VarCharValue + '%'
AND
(
(@Section IS NULL )OR
(@Section IS NOT NULL AND c.section LIKE '%' + @Section + '%' )
)
AND
(
(@ArticleId IS NULL )OR
(@ArticleId IS NOT NULL AND c.contentid <> @ArticleId )
)
And
(
(@IncludeDeleted = 1) Or
(c.priority > 0)
)
)
Select Distinct
contentid, title, section, keyword, priority, description
FROM CTE
Where (@CountID Is Null) Or (@CountID >= rank)
Looking at the procedure, it shouldn't have a semi colon where it does, but still I would expect the application to be able to handle it.
This has been fixed in EA2 (v0.2.1), which was released on Mon 22 Feb 2010.
-
Steve Ryabinky commented
I am getting the same error but the cause is not ";". I have a schema name "MERGE" in the database and get following errors:
#oEc.#8Jf: Errors occured whilst parsing file ...\Local Settings\Application Data\Red Gate\SQL Source Control 0\WorkingBases\y305tcxy.5r2\Stored Procedures\MERGE.mergemain.sql
'line 65:21: unexpected token: ["MERGE",<888>,line=65,col=21] [char=1526]'
'line 66:21: unexpected token: ["merge",<888>,line=66,col=21] [char=1586]'
'line 67:21: unexpected token: ["merge",<888>,line=67,col=21] [char=1667]'
'line 68:21: unexpected token: ["MERGE",<888>,line=68,col=21] [char=1728]'
'line 69:21: unexpected token: ["MERGE",<888>,line=69,col=21] [char=1791]'
'line 70:21: unexpected token: ["MERGE",<888>,line=70,col=21] [char=1854]'
'line 71:21: unexpected token: ["merge",<888>,line=71,col=21] [char=1927]'
'line 72:21: unexpected token: ["MERGE",<888>,line=72,col=21] [char=1988]'
'line 74:21: unexpected token: ["MERGE",<888>,line=74,col=21] [char=2050]'
'line 75:21: unexpected token: ["MERGE",<888>,line=75,col=21] [char=2123]' -
Bernard commented
I can confirm I see the same problem - and SQL ReFactor aslo chokes on this.
-
digiguru commented
To confirm, it only seems to happen when there are stored procedures where ";" is the first in the query (after removing commented out text)