简体   繁体   中英

Compatibility issue between H2 DB queries and Sql Server

I'm developing an application which uses the H2 DB . But the queries which are in the H2 supported grammar are not supported by Sql server and vice versa . Is there any way to make the application work with a common query structure which supports both H2 and Sql Server ? Here are my queries .. 1st Query

SQL Server Syntax -

SELECT columns INTO  table_1 FROM table_2  WHERE conditions

H2 DB equivalent

CREATE TABLE table_1 AS  SELECT columns FROM table_2 WHERE conditions

*The above H2 query wasnt supported by SQL Server

2nd Query

SQL Server Syntax

UPDATE a SET columns FROM table_1 a JOIN table_2 b on keys WHERE conditions  INSERT INTO table_1(columns) SELECT columns FROM  table_2 WHERE conditions

H2 DB equivalent

1st part

 UPDATE table_1 a  SET column=(SELECT column FROM table_2 b WHERE conditions) 

2nd part

 INSERT INTO table_1(columns) SELECT columns FROM  table_2 WHERE conditions

Yes, rewrite the queries.

The proper way to do that would be to create the target table and then say:

INSERT INTO table2
SELECT ... FROM table1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM