--USE [master]
--SELECT * FROM INFORMATION_SCHEMA.columns --某数据库中所有表的"字段"列表
----------------------------------------------------------------------------------------
DECLARE @TempTable TABLE
(
RowNumber INT,
UID INT
)
INSERT
@TempTable
SELECT ROW_NUMBER()OVER(ORDER BY UserID) AS RowNumber ,dbo.Users.UserID AS UID
--into #depTemp--在数据库中建立临时表 并插入数据
FROM dbo.Users
SELECT * FROM @TempTable
--用来获得最大的rowNumber
DECLARE @max int
SELECT @max=max(rownumber) from @TempTable
DECLARE @rowNo INT
SET @rowNo=1
WHILE @rowNo<=@max --用来对每一个rowNumber来进行循环操作
BEGIN --此处对每一行要进行的操作的代码
SELECT * FROM @TempTable WHERE @TempTable.RowNumber=@rowNo
SET @rowNo=@rowNo+1
END
--drop table #depTemp--清除临时表
--SELECT * FROM INFORMATION_SCHEMA.columns --某数据库中所有表的"字段"列表
----------------------------------------------------------------------------------------
DECLARE @TempTable TABLE
(
RowNumber INT,
UID INT
)
INSERT
@TempTable
SELECT ROW_NUMBER()OVER(ORDER BY UserID) AS RowNumber ,dbo.Users.UserID AS UID
--into #depTemp--在数据库中建立临时表 并插入数据
FROM dbo.Users
SELECT * FROM @TempTable
--用来获得最大的rowNumber
DECLARE @max int
SELECT @max=max(rownumber) from @TempTable
DECLARE @rowNo INT
SET @rowNo=1
WHILE @rowNo<=@max --用来对每一个rowNumber来进行循环操作
BEGIN --此处对每一行要进行的操作的代码
SELECT * FROM @TempTable WHERE @TempTable.RowNumber=@rowNo
SET @rowNo=@rowNo+1
END
--drop table #depTemp--清除临时表