sql table 迴圈
SET NOCOUNT ON
DECLARE @docId VARCHAR(10)
DECLARE MYCURSOR CURSOR FOR
--下面放你要跑迴圈計算筆數的SQL
select docId from t1
OPEN MYCURSOR
FETCH NEXT FROM MYCURSOR INTO @docId
WHILE @@FETCH_STATUS = 0
BEGIN
--這邊放你要跑迴圈的 SQL
print('a')
FETCH NEXT FROM MYCURSOR INTO @docId
END
CLOSE MYCURSOR
DEALLOCATE MYCURSOR
標籤: SQL
0 個意見:
張貼留言
訂閱 張貼留言 [Atom]
<< 首頁