Search code examples
sql-servermergedbvisualizer

MERGE INTO DbVisualizer not worknig


Heelo everyone,

I'm trying to use Merge INTO to update my table from another table like that example here:

MERGE INTO locations l USING new_locations n         
ON (l.customer_id = n.customer_id              
AND l.location_x = n.location_x 
AND             l.location_y = n.location_y)   
WHEN MATCHED THEN UPDATE SET location_count = l.location_count + n.location_count   
WHEN NOT MATCHED THEN INSERT (customer_id, location_x, location_y, location_count, location_name)        
VALUES (n.customer_id, n.location_x, n.location_y, n.location_count, n.location_name);

i'm using MSSQL and connect via DbVisualizer and ODBC brideg.

when i run the command it state: General error;

after some search i found here that you have to use this format for Mere into in VbVisualizer:

@delimiter %%;
MERGE x AS y<code here>
;
@delimiter ;%% 

when i did it this way the program hang on : Parsing the script. I tried to change the default statement separator for DbVisualizer but still no luck

/***********************************Editing ****************************/ Parsing error

If i removed the i get

09:27:46  [MERGE - 0 row(s), 0.000 secs]  [Error Code: 10713, SQL State: 37000]  [Microsoft][ODBC SQL Server Driver][SQL Server]A MERGE statement must be terminated by a semi-colon (;).

if i used the tool properties Statement Delimeters and replace the (;) with GO i get the following error

09:29:24  [MERGE - 0 row(s), 0.000 secs]  [Error Code: 0, SQL State: S1000]  General error

/*******************************End Editing ****************************/

can you help me? thanks


Solution

  • It Seems that because Merge is a transact/SQL query it needs multi line to commit the transaction which DB visualizer does not allow in the free version :(

    hope I could find alternative.