Maison > base de données > tutoriel mysql > SQL 循环插入1000条数据

SQL 循环插入1000条数据

大家讲道理
Libérer: 2016-11-12 10:33:26
original
3585 Les gens l'ont consulté

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 = &#39;A9B47402-ADA9-E311-A64D-782BCB92E944&#39;
Set @i =@i +1
set @identifier = NewID()
set @Uuid = NewID()
Set @ProductName = &#39;VMWare Virtual Machine 10&#39;
set @ProtectFlag = 0
set @name = RIGHT(&#39;vm-test&#39; + CAST(@i AS nvarchar(MAX)),20)
set @ManagedStatus = 2
set @SummaryStatus = 32
Set @Location = &#39;Storage_1.82T&#39;
set @SubstanceFlag = 1
set @type = 1114112
set @path = RIGHT(&#39;[Storage_1.82T] vm1_ByVMClone/vm-test.vmx&#39; + cast(@i AS nvarchar(MAX)), 50)
set @ManagedSubStatus = 1
set @ThreadId =&#39;4&#39;
set @LastUpdateDate = cast(&#39;2014-03-12 14:10:56.660&#39; as datetime)
set @managerId1 = &#39;4DEB2D12-ADA9-E311-A64D-782BCB92E944&#39;
set @managerId2 = &#39;E1F45D47-B7BF-E311-A9C7-782BCB92E944&#39;
 
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
Copier après la connexion

source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal