简体   繁体   English

SQL查询在SQL Server Compact Edition中不起作用

[英]SQL query doesn't not work in SQL Server Compact Edition

How to use insert into ... where ( .. ) in SQL Server ce? 如何在SQL Server中使用insert into ... where ( .. )

This query: 这个查询:

insert into table(field) values(@val) 
where not exists (select field from table where field = @code);

returns 回报

There was an error parsing the query. 解析查询时出错。 [ Token line number = 1,Token line offset = 40,Token in error = where ] [令牌行号= 1,令牌行偏移= 40,令牌错误=其中]

How I fix this? 我怎么解决这个问题? Thanks in advance 提前致谢

You will have to do this the old-fashioned way: select the record in question from the database and, if it does not exist, perform the insert. 您将不得不采用老式的方法:从数据库中选择有问题的记录,如果不存在,则执行插入。

Here's a link to the relevant MSDN documentation. 这是相关MSDN文档的链接

I'm pretty sure that your issue is the "NOT EXISTS", as SQL CE just doesn't support that. 我很确定您的问题是“ NOT EXISTS”,因为SQL CE不支持。 Here's a link to a similar question that might help: “If not exists” fails on SQL CE 以下是一个可能会有所帮助的类似问题的链接: SQL CE上的“如果不存在”失败

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

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