Home Forums SQL Server 7,2000 General Inserting multiple rows using stored procedure RE: Inserting multiple rows using stored procedure

  • karthimca07 (7/8/2009)


    Hi All,

    Tab_Token_Master(Transid,Token_starts_from,Token_Ends_To,Token_value)

    Tab_Token_Details(Transid,Token_No,Token_Value,Token_Status)

    [p]The first table is used to store the token starting number and end number.[/p]

    [p]for example (staring number)1 to 100(ending number). so i have to insert token1,token2...token100 in tab_Token_details table.[/p]

    [p]how can i insert that number of records using stored procedure?

    is there for loop to do this task?

    plz help me in this issue?

    thnks in advance[/p]

    declare @Transid int, @TokenStart int, @TokenEnd int, @TokenValue int

    insert into dbo.Tab_Token_Details (Transid, Token_No, Token_Value, Token_Status)

    select

    @Transid,

    N,

    @TokenValue,

    'A' -- or whatever your status field should be

    from dbo.Tally

    where N between @TokenStart and @TokenEnd

    If you don't have a tally table, search this site... it's explained and used frequently.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2