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 |
|
vin
Starting Member
26 Posts |
Posted - 2003-05-17 : 03:58:57
|
| Hi,I am using SQL server 2000, and facing one problem using cursors.Can you any body tell me how to use WHERE CURRENT OF clause.I am posting my sample code hereDeclare @Temp_emp_id varchar(9),@Temp_job_id smallintselect @Temp_emp_id = null,@Temp_job_id = 0DECLARE emp_cursor CURSOR FORSELECT emp_id,job_ib FROM emporder by emp_idOPEN emp_cursor-- Perform the first fetch.FETCH NEXT FROM emp_cursor into @Temp_emp_id, @Temp_job_idWHILE @@FETCH_STATUS = 0BEGIN if (@Temp_job_id = 13) begin update emp set processed = 1 --where current of emp.job_id where job_id = @Temp_job_id end FETCH NEXT FROM emp_cursor into @Temp_emp_id,@Temp_job_idENDCLOSE emp_cursorDEALLOCATE emp_cursorError : Server: Msg 207, Level 16, State 3, Line 9Invalid column name 'job_ib'.The emp table contains Job_id column. The structure of emp is emp_id varchar(9)job_id samllintprocessed tinyint if some body help me how to resolve this.Thanks & RegardsVinay |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-05-17 : 07:32:50
|
| How about:UPDATE emp SET processed=1 WHERE job_id=13You certainly don't need a cursor for a simple UPDATE like this. |
 |
|
|
|
|
|