October 11, 2011 at 10:44 am
Hi Experts,
I am trying a hand on MERGE statement. When executing the following code results in a error :
"A MERGE statement must be terminated by a semi-colon (;)"
I could not find the document related to this issue on msdn.
Am I missing on something .. Please help.
MERGE SURFBI_DASHBOARDS TGT
USING (SELECT 'DASH1' DASHBOARD_NAME, 1 INSTALL_ID) SRC
ON (SRC.DASHBOARD_NAME = TGT.DASHBOARD_NAME AND SRC.INSTALL_ID = TGT.INSTALL_ID)
WHEN MATCHED THEN
UPDATE SET TGT.EFFECTIVE_START_DATE = NULL,
TGT.EFFECTIVE_END_DATE = NULL,
TGT.UPDATED_BY = 1,
TGT.UPDATION_DATE = GETDATE(),
TGT.COMMENTS = NULL
WHEN NOT MATCHED THEN
INSERT(
INSTALL_ID,
DASHBOARD_NAME,
EFFECTIVE_START_DATE,
EFFECTIVE_END_DATE,
CREATED_BY,
CREATION_DATE,
UPDATED_BY,
UPDATION_DATE,
COMMENTS,
IS_ENABLED
)
VALUES(1, 'DASH1', NULL, NULL, 0, GETDATE(), NULL, GETDATE(), NULL, 'Y');
October 11, 2011 at 10:50 am
The MERGE SQL statement requires a semicolon (;) as a statement terminator. Otherwise Error 10713 is raised when a MERGE statement is executed without the statement terminator.
Its just the way Merge code is handled in SQL. (SYNTAX)
______________________________________________________________________
Ankit
MCITP Database developer SQL 2008,MCTS Database Administration SQL 2008
"Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose.
You are already naked. There is no reason not to follow your heart.”
October 11, 2011 at 10:57 am
Thanks for bringing it to notice. I think i am using the semicolon(;) in the end after the values(..) ;
I have hanging around it since morning..Please provide with some suggestions.. Thanks in advance
October 11, 2011 at 11:31 am
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Please post some data according to the article to check the same.
______________________________________________________________________
Ankit
MCITP Database developer SQL 2008,MCTS Database Administration SQL 2008
"Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose.
You are already naked. There is no reason not to follow your heart.”
October 11, 2011 at 11:35 am
Betn remove "TGT. " in the Update statement as it will automatically comsider it target
______________________________________________________________________
Ankit
MCITP Database developer SQL 2008,MCTS Database Administration SQL 2008
"Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose.
You are already naked. There is no reason not to follow your heart.”
October 11, 2011 at 11:48 am
You just have to use ; in the end of Merge Statement which I see you put it there...So it shouldn't be any error if you do it
[font="Arial Black"]Performance Guard[/font]
[font="Courier New"]Just ask me to get 0 sec for all queries[/font]
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply