SqlServer 批量添加记录

declare @i int
set @i=1
while(@i<=10)
begin


INSERT INTO [dbo].[Settlements]
           ([ID]
           ,[Count]
           ,[SettlementDate])
     VALUES
           (

       newid() ,cast( floor(rand()*100) as int) --随机int ,DATEADD(DAY,1,(select top 1 [SettlementDate] from [Settlements] order by [SettlementDate] desc )) --获取表中最大的日期然后加1
      )
set @i=@i+1 end

 

posted @ 2017-10-24 13:49  幸福安康  阅读(626)  评论(0编辑  收藏  举报