SQL cursor operation

xiaoxiao2021-04-07  285

SELECT Count (ID) from info

SELECT * from info

- Clear all records TRUNCATE TABLE INFO

Declare @i int set @ i = 1WHILE @i <1000000begin insert Into info value ('Justin' Str (@i), 'Shenzhen' Str (@i)) set @ i = @ i 1nd

- Declaration Cursor Declare My_CURSOR CURSOR KeySet for Select * from info - Delete Cursor Resources DEAllocate My_CURSOR

- Open the cursor, valid before the cursor close or delete Open my_cursor - Close the cursor close my_cursor

- Declaration local variable declare @ID int, @ name varchar (20), @ address varchar (20) - Logging to the specified location Fetch absolute 56488 from my_cursor @ id, @ name, @ addressselect @ID AS ID, @name as name, @ address as address - positioning to the current record relative location Record Fetch Relative -88 from my_cursor @ id, @ name, @ addressselect @id as id, @ name as name, @ address as address - positioning Go to the current record previous fetch prior from my_cursor @ id, @ name, @ addressselect @id as id, @ name as name, @ address as address - positioned to the current record after a fetch next from my_cursor INTO @ ID, @ Name , @ addressselect @ID as ID, @ name as name, @ address as address - positioning to the first record fetch first from my_cursor @ id, @ name, @ addressselect @id as id, @ name as name, @ address as address - Positioning to the tail record fetch last from my_cursor @ id, @ name, @ addressselect @id as id, @ name as name, @ address as address

转载请注明原文地址:https://www.9cbs.com/read-132655.html

New Post(0)