Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
reacha
Starting Member
49 Posts |
Posted - 2010-10-13 : 15:11:37
|
| I have a cursordeclare cursor_AUDIT_MetricsInter cursorfast_forward READ_ONLYFor select pkgid from AUDIT_MetricsInterpwhere AuditStampCompleted is null open cursor_AUDIT_MetricsInterfetch next from cursor_AUDIT_MetricsInter into @pkgidbut i thought of using temporary variable insert into @temp2(pkgid)select pkgid from AUDIT_MetricsInterpwhere AuditStampCompleted is null In this temp variable how can i go thorugh the next recordPlease help me out!! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
reacha
Starting Member
49 Posts |
Posted - 2010-10-13 : 15:25:31
|
| i need to go though each and every pkgid and need to pass that pkgid into 2 procedures and 1 function and get the other column values from there and after than in this main procedure where i am using cursor needs to update the table with the values returned by procedure for each and every pkgidexec [msp_UseridAuditStampCompleted]@pkgid,@AuditStampCompleted = @AuditStampCompleted output,@userID = @userid outputexec [msp_EventIDAuditStampQueueEntered]@pkgid,@AuditstampQueueEntered = @AuditstampQueueEntered output,@QueueEventID = @QueueEventID outputset @AuditStampLocked = (SELECT [dbo].[mfun_AuditStampLocked] (@pkgid)) UPDATE AUDIT_MetricsInterpSET USERID = @userid,QueueEventID = @QueueEventID,AuditStampLocked=@AuditStampLocked,AuditStampCompleted = @AuditStampCompleted,AuditstampQueueEntered=@AuditstampQueueEntered WHERE PKGID = @pkgid |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
reacha
Starting Member
49 Posts |
Posted - 2010-10-13 : 15:32:21
|
| No other alternative way because i have one and half million records means pkgid's means it is going to each and every pkgid and getting data.just to update 9000 records it is taking 45minHow can i avoid the cursor from doing dirty reads |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|