--以下可行性未经验证
--有条件的插入语句:
--先查maxid
select max(id) as 'Id' from [test].[dbo].[mytable]
--用处:用maxid来避免重复插入
insert [test].[dbo].[mytable]
select '999' as 'CostItem','20220407' as 'UpdateTime','0' AS 'IsDel',null AS 'UserName','0' AS 'Schducle'
where exists (select 1 from (select max(Id) as 'maxid' from [dbo].mytable)t where t.maxid='116')
Sql有条件的插入语句
最新推荐文章于 2025-03-22 02:13:38 发布