tsql - SQL Server 2000 Update based on nested SELECT with TOP -


i trying update sql table x amount of rows ordered query, x balance of 100000 - previous result. using rowcount limit number of results due x being parameter don't think works.

can suggest fix or alternative without cursors?

declare @top int set @top = 100000 - @countrecords  set rowcount  @top   update      updatetable set      updatefield = 'somevalue'      id in     (         select             top 100% id                      selecttable                       (selectfield1 null) ,                     (selectfielddate not null)             order                      selectfielddate                              )  set rowcount 0 

set rowcount applies intermediate results can misleading

if load temp table, can bypass separating update 2 steps

declare @top int set @top = 100000 - @countrecords  set rowcount  @top   select id #foo      selecttable       (selectfield1 null) ,             (selectfielddate not null) order      selectfielddate                  set rowcount 0  update      updatetable set      updatefield = 'somevalue'      id in     (         select id #foo     ) 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -