使用遊標讀取數據的操作
DECLARE E1cursor cursor /* 聲明遊標,默認爲FORWARD_ONLY遊標 */
FOR SELECT * FROM c_example
OPEN E1cursor /* 打開遊標 */
FETCH NEXT from E1cursor /* 讀取第1行數據*/
WHILE @@FETCH_STATUS = 0 /* 用WHILE循環控制遊標活動 */
BEGIN
FETCH NEXT from E1cursor /* 在循環體內將讀取其餘行數據 */
END
CLOSE E1cursor /* 關閉遊標 */
DEALLOCATE E1cursor /* 刪除遊標 */
select zydm,zymc from CM_T_JHK_temp where zydm not in (select zydm from CM_professional )
select * from CM_professional where zydm='101'
delete CM_professional
declare newzy_cursor cursor
for select zydm from cm_t_jhk_temp
open newzy_cursor
declare @zydm varchar(10)
fetch next from newzy_cursor into @zydm
while @@fetch_status=0
begin
print '專業代碼: ' + @zydm
fetch next from newzy_cursor into @zydm
end
close newzy_cursor
deallocate newzy_cursor
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.