首页 > 代码库 > T-sql 遍历结果集

T-sql 遍历结果集

DECLARE @TAB TABLE(	[科室编号] [varchar](50) NULL,	[科室编码] [varchar](50) NULL,	[科室名称] [varchar](50) NULL,	[拼音] [varchar](50) NULL)INSERT INTO @TABSELECT * FROM Table_uvi_deptSELECT * FROM @TABWHILE((SELECT COUNT([科室编号]) FROM @TAB)>0)BEGINPRINT 1DELETE @TAB WHERE [科室编号]=(SELECT TOP 1 [科室编号] from @TAB)END