Get row count and data set from sproc
-
I am currently using a sproc like the one below to get both a dataset and a count of the rows returned. Is there a better way to do this?
@Filter int, @theRows int output
AS
BEGIN
SELECT
Field1,
Field2
FROM
MyTable
WHERE
FilterField=@FilterSET @theRows=(select count(\*) from MyTable WHERE FilterField=@Filter)
END
Thanks.
-
I am currently using a sproc like the one below to get both a dataset and a count of the rows returned. Is there a better way to do this?
@Filter int, @theRows int output
AS
BEGIN
SELECT
Field1,
Field2
FROM
MyTable
WHERE
FilterField=@FilterSET @theRows=(select count(\*) from MyTable WHERE FilterField=@Filter)
END
Thanks.
-
Try this
@Filter int, @theRows int output
AS
BEGIN
SELECT Field1, Field2
FROM MyTable
WHERE FilterField=@FilterSELECT @theRows = @@ROWCOUNT
ENDBob Ashfield Consultants Ltd
-
I am currently using a sproc like the one below to get both a dataset and a count of the rows returned. Is there a better way to do this?
@Filter int, @theRows int output
AS
BEGIN
SELECT
Field1,
Field2
FROM
MyTable
WHERE
FilterField=@FilterSET @theRows=(select count(\*) from MyTable WHERE FilterField=@Filter)
END
Thanks.
Hi.. Sure You Can Have This One....
@Filter int,
@theRows int output
AS
BEGIN
SET @theRows=(SELECT Count(Field)
FROM MyTable
WHERE FilterField=@Filter)
ENDHope It Will work... do Reply.. Have Nice Day.. :-D