CREATE TABLE nametable (nameguid uniqueidentifier,name nvarchar (Ten) ) insert into nametable (nameguid,name) VALUES (NEWID (),'Lide') insert into nametable (nameguid,name) VALUES (NEWID (),'Lideqiang') insert into nametable (nameguid,name) VALUES (NEWID (),'Liqiang')SetRowCount1Select* fromNameTable
The role of SET ROWCOUNT is to cause SQL Server to stop processing queries after returning the specified number of rows.
Output Result:
To implement table traversal:
Declare @nameguid uniqueidentifierDeclare @name nvarchar(Ten) while exists(Select * fromnametable)beginSet RowCount 1Select @nameguid =Nameguid fromNameTableSelect @name =Name fromNameTablewhereNameguid= @nameguidSet RowCount 0Delete fromNameTablewhereNameguid= @nameguidPrint @nameEnd
However, this removes data from the table and can be manipulated in a temporary table
Select * into from NameTable
SQL does not use cursors to traverse table data