简体   繁体   English

H2 DB查询和Sql Server之间的兼容性问题

[英]Compatibility issue between H2 DB queries and Sql Server

I'm developing an application which uses the H2 DB . 我正在开发一个使用H2 DB的应用程序。 But the queries which are in the H2 supported grammar are not supported by Sql server and vice versa . 但是Sql server不支持H2支持的语法中的查询,反之亦然。 Is there any way to make the application work with a common query structure which supports both H2 and Sql Server ? 有什么方法可以使应用程序使用支持H2和Sql Server的通用查询结构? Here are my queries .. 1st Query 这是我的查询..第一个查询

SQL Server Syntax - SQL Server语法-

SELECT columns INTO  table_1 FROM table_2  WHERE conditions

H2 DB equivalent 相当于H2 DB

CREATE TABLE table_1 AS  SELECT columns FROM table_2 WHERE conditions

*The above H2 query wasnt supported by SQL Server * SQL Server不支持上述H2查询

2nd Query 第二查询

SQL Server Syntax SQL Server语法

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 相当于H2 DB

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 插入表2
SELECT ... FROM table1 SELECT ... FROM table1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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