how to store multiple rows in a stored procedure's parameters and then insert them in a table

  • aeri_q (10/17/2013)


    it returns 3 rows for a specific table of my database.

    But when i wrote stored procedure using the same query it inserted the first row in my table. (The first of the 3 rows which where returned by the query,when executed alone)

    it will because .

    you below query will basically executed ONE time during every Sp execution and fill all the variable of INSERT statement once.

    INSERT INTO SY.DB03F(FKNAME,SCHM,FKFLD,FKTBL,PKFLD,PKTBL)

    VALUES(

    @FKNAME,

    @SCHNAME,

    @FKFLDNAME,

    @FKTBLNAME,

    @PKFLDNAME,

    @PKTBLNAME)

    Instead .... go with the query which OTF mentioned and use it in place of above SQL insert. .

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • Ohh thank you so much ,

    It was just a little and silly mistake i was doing .

    INSERT ..SELECT works fine in this case .

  • Glad we could help.

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply