Delete into SQL Server loop -


in case of repetition periods, need delete second occurrence (15 15 minutes), query returns or nothing.

declare @datatetemp date declare @horatetemp time  declare cursor_i cursor select datate, horate @table  open cursor_i fetch next cursor_i @datatetemp, @horatetemp;  while @@fetch_status = 0     begin          if  (select count(*) @table horate = dateadd(minute, -15, @horatetemp)) > 0         --dateadd(minute, -15, @horatetemp) = @horatetemp         begin             delete @table current of cursor_i         end          fetch next cursor_i @datatetemp, @horatetemp     end  close cursor_i; deallocate cursor_i; 

another:

declare @aux time = dateadd(minute, -15, @horatetemp) if  (select count(*) @table oito oito.horate = @aux) > 0 

would never possible applying as:

select [...] cross apply dbo.function(dat, hor) [...] 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -