日期:2014-05-17  浏览次数:20461 次

求改造
下面这两句sql语句可以在sqlServer中一次执行,但在ACCESS是不行,能否改造可以在ACCESS一次执行?

Update comParams Set ParamValue = 'XXXX' Where ParamName = 'CorpFullName' 
if @@RowCount = 0 
begin 
  Insert Into comParams(ParamName,ParamValue) Values('CorpFullName','XXXX') 
end


------解决方案--------------------
Access是因为没有@@rowcount吧,你查查Access有没有相关的函数?不过我觉得应该没有,微软对它的开发力度不会很大的。如果没有,那就用笨方法,if(select count(1) from comParams Where ParamName = 'CorpFullName' and ParamValue = 'XXXX')>0来替代,试试
------解决方案--------------------
楼上正解
------解决方案--------------------
SQL code

--这样写access应支持的吧
Update comParams Set ParamValue = 'XXXX' Where ParamName = 'CorpFullName' 
Insert Into comParams(ParamName,ParamValue) 
    select 'CorpFullName','XXXX'
    where not exists (select 1 from comParams where ParamName='CorpFullName')

------解决方案--------------------
支持楼上一下
------解决方案--------------------
探讨
SQL code

--这样写access应支持的吧
Update comParams Set ParamValue = 'XXXX' Where ParamName = 'CorpFullName'
Insert Into comParams(ParamName,ParamValue)
select 'CorpFullName','XXXX'
where not ……