Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
1.44/5 (3 votes)
See more:
I need procedure to Insert many Number In Table
I need To Use In C#
Like This:
SQL
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

How Can Use This Code In Windows Form
I need To Pass Tow Parameter
1-@count
2-@num
Posted
Updated 26-Feb-20 23:01pm
v2
Comments
Thava Rajan 14-Oct-15 9:41am    
what is wrong with that sql statement?
why did you go to the front end?
what is the real issue to you?

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

SQL
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


Refer: How To Write a Stored Procedure in SQL Server[^]
 
Share this answer
 
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[^]
 
Share this answer
 
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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900