如何使用循环插入创建过程 [英] How Can create procedure with loop insert

查看:73
本文介绍了如何使用循环插入创建过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在表格中插入多个数字的程序

我需要在C中使用#

喜欢这个:

I need procedure to Insert many Number In Table
I need To Use In C#
Like This:

DECLARE 
@count INT,
@num int 
SET @count = 0155460000
SET @num = 15546
WHILE (@count <=  155462000)
BEGIN
   INSERT INTO TestCodeTBL (CodeNumbber,CodeWithSerial) VALUES (@count, @num) 
   SET @count = (@count + 1 )  
END



如何在Windows窗体中使用此代码

我需要通过拖动参数

1- @count

2- @ num


How Can Use This Code In Windows Form
I need To Pass Tow Parameter
1-@count
2-@num

推荐答案

为了帮助您入门,这里是sproc :



Just to help you getting started, here is the sproc:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE AddTestCodeTBL
    @count INT,
    @num INT
AS
BEGIN

    SET NOCOUNT ON;

    WHILE (@count <=  155462000)
    BEGIN
        INSERT INTO TestCodeTBL (CodeNumbber,CodeWithSerial) 
        VALUES (@count, @num) 
        
        SET @count = (@count + 1 )  
    END

END
GO





参考:如何在SQL Server中编写存储过程 [ ^ ]


在SQL中实现循环概念时使用Do;有关如何在SQL Server中实现while循环的更多详细信息,请参阅以下链接在SQL Server中循环 [ ^ ]
Using Do while you can achieve looping concept in SQL; Refer below link for more details how to implement While loop in SQL Server While Loop in SQL Server[^]


在此处了解如何创建存储过程: https://msdn.microsoft.com/en-us/library /ms345415.aspx [ ^ ]

比这里学习如何从C#(ADO.NET)调用这样的存储过程: http://www.c-sharpcorner.com/UploadFile/gtomar/storedprocedure12052007003126AM/storedprocedure.aspx [ ^ ]
Learn how to create a stored procedure here: https://msdn.microsoft.com/en-us/library/ms345415.aspx[^]
Than learn how to call such stored procedure from C# (ADO.NET) here: http://www.c-sharpcorner.com/UploadFile/gtomar/storedprocedure12052007003126AM/storedprocedure.aspx[^]


这篇关于如何使用循环插入创建过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆