在访问数据库中备用 [英] Alternate in access database

查看:99
本文介绍了在访问数据库中备用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Access 2007中插入一个新的行之前检查一行是否存在。

我在SQL Server中有以下工作查询,但我无法将其转换为Access。 / p>

I want to check whether a row exists or not before inserting a new one in Access 2007.
I have the following working query in SQL Server but I'm having trouble converting it to Access.

update category set name='hell' where categoryid=287
if @@rowcount=0
begin
insert into category(categoryid,name,path,parentcategoryid,creationdate) values (287,'a','a',12,'')
end


推荐答案

尝试这个

update category set name='hell' where categoryid=287;

if not exists(select * from Category where categoryid=287)
    insert into category(categoryid,name,path,parentcategoryid,creationdate) 
values (287,'a','a',12,'');

这篇关于在访问数据库中备用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆