Home Forums SQL Server 2008 SQL Server Newbies how to store multiple rows in a stored procedure's parameters and then insert them in a table RE: 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;-)