SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


select the output of stored procedure with count of returned rows


select the output of stored procedure with count of returned rows

Author
Message
ali.m.habib
ali.m.habib
SSC Veteran
SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)

Group: General Forum Members
Points: 204 Visits: 163
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 ')'.
brad.mason5
brad.mason5
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1808 Visits: 2055
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search