10
如何在SQL Server中编写foreach?
我正在尝试按照for-each的方式实现某些目标,在这里我想获取返回的select语句的ID并使用它们中的每一个。 DECLARE @i int DECLARE @PractitionerId int DECLARE @numrows int DECLARE @Practitioner TABLE ( idx smallint Primary Key IDENTITY(1,1) , PractitionerId int ) INSERT @Practitioner SELECT distinct PractitionerId FROM Practitioner SET @i = 1 SET @numrows = (SELECT COUNT(*) FROM Practitioner) IF @numrows > 0 WHILE (@i <= (SELECT MAX(idx) …
192
sql-server
tsql