About 1,550,000 results
Open links in new tab
  1. SQL Server: Using cursor to loop and insert incremental values

    Sep 20, 2019 · select isnull(@max, 0) + 1 as ReqDocNo, 2 as ctr. union all . select isnull(@max, 0) + ctr, ctr + 1 from cte . where ctr <= @max. ,convert(date, pick_up_date, …

  2. How to query-and-increase a value (counter) in a thread-safe way ...

    May 29, 2015 · In a table where each row has a counter (just an integer value), I need to get the current value and increase it at the same time. Effectively, I want to do this: SELECT counter …

  3. Loop through table rows with Cursor in SQL Server - ASPSnippets

    Feb 2, 2025 · In this article I will explain with an example, how to loop through table rows with Cursor in SQL Server. Cursor is supported in following SQL Server versions i.e. 2008, …

  4. sql - How to increment in a select query - Stack Overflow

    One way to do this is to throw the data into a temp table with an identity column that is used as a row number. Then make the counter column a count of the other rows with the same Id and a …

  5. Incrementing counters in database – select * from depesz;

    Jun 14, 2016 · $ select current_value + coalesce ((select sum (value_change) from counters_queue where counter_name = 'whatever'), 0) from counters where counter_name = …

  6. Conditionally Incrementing a Counter in a While Loop

    Jul 18, 2006 · @i = @i + 1, @interval = @interval + 1, RandomDate = case when @i <= 20 and @interval % 2 = 0 then r. RandomDate else pt. RandomDate end. ON pt. UID = r.

  7. Populate SQL Server Column with Sequential Number without …

    Feb 18, 2022 · Using an Identity Column to Increment the Value by 1. In this example we are going to create a table (to mimic a table that already exists), load 100,000 records and then …

  8. sql server - How to update ID=null values in table to incremental ...

    The NaturalID can uniquely identify an entry (in fact, it's multiple columns). I want to set the "null" IDs to incremental values, following the current max ID, here: 5 and 6, increasing when more …

  9. Update numeric field + 1 (increment) - SQL Server Forums - SQLTeam.com

    Sep 16, 2008 · I would like to update a number field in a table by incrementing the numbers by 1. Kind of like an auto number. I have been trying to use an update statement with count + 1 but …

  10. Implement Incrementing Counter in SQL - Stack Overflow

    Jan 8, 2021 · In MS SQL Server, is there a way to "atomically" increment a column being used as a counter?

Refresh