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???
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.
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