CREATE PROCEDURE dbo.[xxx] as if ( (select count(1) from [tb]) >= 500 ) trucate table [tb]
假设有个id池,id最大为5. 能不能 在id<5的时候 insert 在id>5的时候从id=1开始update CREATE PROCEDURE dbo.qq as begin if ( (select count(1) from [table_3]) >= 5 ) ------update table_3 set name='yangjia' where id=1 --从id=1开始更新,这具话咋写?? else((select count(1) from [table_3]) < 5) insert table_3 (name) values ('yangjia') end
写成个exe,用window的执行计划调用行不?
as
if ( (select count(1) from [tb]) >= 500 )
trucate table [tb]
能不能 在id<5的时候 insert 在id>5的时候从id=1开始update
CREATE PROCEDURE dbo.qq
as
begin
if ( (select count(1) from [table_3]) >= 5 )
------update table_3 set name='yangjia' where id=1 --从id=1开始更新,这具话咋写??
else((select count(1) from [table_3]) < 5)
insert table_3 (name) values ('yangjia')
end