|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Update limit in a stored procedure
I have a table with more then 20,000 records. this table has a record_id column. I want to change the record_id values based on a different sorting.
I wrote a stored procedure using a cursor running over all the records in that table (in the new order) and then for each record assign a new record_id. when I run the stored procedure without the update, I get all 22,798 records. when I run it with the update I get only 4,838 records. Is there a limit to the amount of record a stored procedure can update? can it be changed? STORED PROCEDURE: CREATE PROCEDURE sft_sort_table as BEGIN DECLARE @record_ID INT DECLARE @MAX_record_ID INT DECLARE @CUR_RECORD_ID INT --Get the max rate_record_id SELECT @MAX_record_ID INT = max(record_id) FROM table DECLARE curRecord CURSOR FOR select record_id from table order by new_sort FOR UPDATE OF record_id OPEN curRecord FETCH NEXT FROM curRecord INTO @CUR_RECORD_ID WHILE @@FETCH_STATUS = 0 BEGIN SET @MAX_RECORD_ID = @MAX_RECORD_ID + 1 PRINT 'Record ' PRINT @CUR_RECORD_ID Print 'will be ' PRINT @MAX_RECORD_ID PRINT '-----------------------------' --Update the record_id UPDATE table SET record_id = @MAX_RECORD_ID WHERE current of curRecord FETCH NEXT FROM curRecord INTO @CUR_RECORD_ID END CLOSE curRecord; DEALLOCATE curRecord; END; |
|
#2
|
||||
|
||||
|
I'm questioning this line?
Code:
UPDATE table SET record_id = @MAX_RECORD_ID WHERE current of curRecord my assumption would be it should be like this Code:
UPDATE table SET record_id = @MAX_RECORD_ID WHERE record_id = OldRecordID |
|
#3
|
|||
|
|||
|
I tried that too, got the same results
this is how I did it before, but it gives me the same results (only4838 records are update)
|
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Update limit in a stored procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|