Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

select the output of stored procedure with count of returned rows Expand / Collapse
Author
Message
Posted Saturday, May 4, 2013 12:52 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Sunday, January 5, 2014 5:16 AM
Points: 64, Visits: 153
I want to select the output of stored procedure and the count of the row affected

So am trying to do something like that

select * , count(*) 
(
if @checker is not null
begin
exec [dbo].[GetEmployees]
@parameter1,
@parameter2
end
else
begin
exec [dbo].[GetEmployees]
@parameter3,
@parameter4
end
)T

I always get error like this
Incorrect syntax near the keyword 'if'.
Incorrect syntax near ')'.
Post #1449392
Posted Saturday, May 4, 2013 1:41 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 10:38 PM
Points: 1,028, Visits: 1,147
ok so you are trying to execute stored proc inside join. Also the IF statement should be outside.

If you can get the date from this stored proc and then count the records.

I am not sure the data set returned but you can.

IF @checker is not null
BEGIN
INSERT INTO #temp
(
column1
,column2
,....

exec [dbo].[GetEmployees]
@parameter1,
@parameter2

END
ELSE
BEGIN
INSERT INTO #temp
(
column1
,column2
,....

exec [dbo].[GetEmployees]
@parameter3,
@parameter4
END

Post #1449394
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse