Last post Nov 08, 2019 05:13 AM by Yang Shen
Nov 07, 2019 04:20 PM|RDesh|LINK
I am looking to get into SQL programming, and Stored Procedures(SP). I have a SP, whose output has a column called 'STATUS'. The values in this column can be 'SUCCESS', 'INPROGRESS', or 'FAILED'. I need a count of all 3. I was trying to do this in my asp
code, in code behind, but am wondering if I can get this done via an SP. I am not sure if I should alter the existing SP, because @@ROWCOUNT gives the # of rows affected. Or if I should create a temporary table as output of the existing SP, and then call another
SP to get the 3 counts.
Looking for some pointers to get me started.
Nov 07, 2019 07:17 PM|limno|LINK
To post a T-SQL question, you need to post your sample table DDL and sample data insert scripts and your expected result from the query you are looking for, It will easy to get help. Thanks.
Nov 08, 2019 05:13 AM|Yang Shen|LINK
If possible, please provide more related information including table structure, sample data and your SP and so on.
Or as you said, you can alter your SP and return what you want from this SP. For this, you can refer to Stored Procedure Output Parameters and Return
Data from a Stored Procedure.
Also below is a simple demo:
ALTER proc [dbo].[selectcount]
select @malecount=(select COUNT(*) from User4Test where Gender='male')
select @femalecount=(select COUNT(*) from User4Test where Gender='female')