USE [InformationSystem] GO /****** Object: StoredProcedure [dbo].[Addcount] Script Date: 05/06/2015 15:29:18 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <> -- Create date: <2015-5-6 15:55:20> -- Description: <存储过程 while循环> -- ============================================= ALTER PROCEDURE [dbo].[pro_whileTest] AS BEGIN DECLARE @n bigint DECLARE @Sql nvarchar(225) DECLARE @GetTime NVARCHAR(225) set @n=0 SET @GetTime= Convert(varchar,getdate(),120) while @n<10 begin Set @Sql=' INSERT INTO [InformationSystem].[dbo].[D_PortlCoutInfo] (readtime,Count,Added,Status) VALUES ('''+@GetTime+''',44,0,0)' PRINT @Sql Exec (@Sql) set @n=@n+1 END END