首页 > 数据库 > mysql教程 > SQL 循环插入1000条数据

SQL 循环插入1000条数据

WBOY
发布: 2016-06-07 14:57:28
原创
1727 人浏览过

自己测试的一个应用 无 DECLARE @i intDECLARE @identifier uniqueidentifierDECLARE @Uuid uniqueidentifierDECLARE @ProductName nvarchar(MAX)DECLARE @ProtectFlag bitDECLARE @name nvarchar(max)DECLARE @ManagedStatus intDECLARE @SummaryStatus intD

自己测试的一个应用
DECLARE @i int
DECLARE @identifier uniqueidentifier
DECLARE @Uuid uniqueidentifier
DECLARE @ProductName nvarchar(MAX)
DECLARE @ProtectFlag bit
DECLARE @name nvarchar(max)
DECLARE @ManagedStatus int
DECLARE @SummaryStatus int
DECLARE @Location nvarchar(MAX)
DECLARE @SubstanceFlag bit
DECLARE @type int
DECLARE @Path nvarchar(max)
DECLARE @ManagedSubStatus int
DECLARE @LastUpdateDate datetime
DECLARE @ThreadId nvarchar(MAX)
DECLARE @managerId uniqueidentifier
DECLARE @managerId1 uniqueidentifier
DECLARE @managerId2 uniqueidentifier

Set @i = 1

WHILE @i < 3000
BEGIN
set @managerId = 'A9B47402-ADA9-E311-A64D-782BCB92E944'
Set @i =@i +1
set @identifier = NewID()
set @Uuid = NewID()
Set @ProductName = 'VMWare Virtual Machine 10' 
set @ProtectFlag = 0
set @name = RIGHT('vm-test' + CAST(@i AS nvarchar(MAX)),20)
set @ManagedStatus = 2
set @SummaryStatus = 32
Set @Location = 'Storage_1.82T'
set @SubstanceFlag = 1
set @type = 1114112
set @path = RIGHT('[Storage_1.82T] vm1_ByVMClone/vm-test.vmx' + cast(@i AS nvarchar(MAX)), 50)
set @ManagedSubStatus = 1
set @ThreadId ='4'
set @LastUpdateDate = cast('2014-03-12 14:10:56.660' as datetime)
set @managerId1 = '4DEB2D12-ADA9-E311-A64D-782BCB92E944'
set @managerId2 = 'E1F45D47-B7BF-E311-A9C7-782BCB92E944'

insert into [dbo].[TBL_Machine]
			([Identifier]
            ,[Uuid]
            ,[ProductName]
			,[ProtectFlag]
            ,[name]
			,[ManagedStatus]
			,[SummaryStatus]
			,[Location]
			,[SubstanceFlag]
			,[OperatingSystemStatus]
			,[Type]
			,[Path]
			,[ManagedSubStatus]
			,[ThreadId]
			,[LastUpdateDate])

			 values
			 (@identifier,
			 @Uuid,
			 @ProductName,
			 @ProtectFlag,
			 @name,
			 @ManagedStatus,
			 @SummaryStatus,
			 @Location,
			 @SubstanceFlag,
			 1,
			 @type,
			 @Path,
			 @ManagedStatus,
			 @ThreadId,
			 @LastUpdateDate)

insert into  [dbo].[TBL_ManagerRelation]
           ([ManagerId]
           ,[TargetId]
           ,[ManagementKey]
           ,[ThreadId]
           ,[LastUpdateDate])
		   values
		   (@managerId,
		   @identifier,
		   @name,
		   @ThreadId,
		   @LastUpdateDate
		   )
insert into  [dbo].[TBL_ManagerRelation]
           ([ManagerId]
           ,[TargetId]
           ,[ManagementKey]
           ,[ThreadId]
           ,[LastUpdateDate])
		   values
		   (@managerId1,
		   @identifier,
		   @name,
		   @ThreadId,
		   @LastUpdateDate
		   )

insert into  [dbo].[TBL_ManagerRelation]
           ([ManagerId]
           ,[TargetId]
           ,[ManagementKey]
           ,[ThreadId]
           ,[LastUpdateDate])
		   values
		   (@managerId2,
		   @identifier,
		   @name,
		   @ThreadId,
		   @LastUpdateDate
		   )

End

登录后复制
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板