SQL Server Performance

return value from an SP

Discussion in 'General Developer Questions' started by nivetha, Jun 9, 2008.

  1. nivetha New Member

    Am executing an SP which returns certain number of rows. I need the number of rows returned from SP1 to use in another SP. How to get it???
  2. Adriaan New Member

    You can use an OUPUT parameter: inside the SP, copy the @@ROWCOUNT value into the parameter immediately after the relevant query statement.
    However, if you're opening a resultset over a connection using ADO or similar, there will be a property for your object on the client side that should reflect the row count as well.
  3. atulmar New Member

    I think this is what you need.CREATE
    PROC P1AS
    SELECT
    * FROM INFORMATION_SCHEMA.SCHEMATA --Just for exampleRETURN
    @@ROWCOUNTgo
    CREATE
    PROC P2AS
    DECLARE @VAR INT
    EXEC @VAR = DBO.P1SELECT
    @VARGO
    EXEC
    dbo.P2
  4. nivetha New Member

    Thanks a lot.[:D]

Share This Page