How to get return rowcount from stored proceedure - SQL Server 2012 -


i writing stored procedure in sql server 2012 , facing problem while reading number of rows stored procedure return after matching conditions , join criteria.

my stored procedure is:

select distinct     count(crs.courseid) over() recordcounts,      crs.courseid,     crs.coursename,     crs.coursedescription,     (select coursegroupname coursegroup cgrp       cgrp.coursegroupid = crs.coursegroupid) category      courses crs  inner join      courserequests creq on crs.courseid = creq.courseid     crs.coursename <> '''' 

it returning 16 "recordcounts" 1 of condition, in actual, result 3 rows only.

can me this?

thanks

below screenshot give more clear idea problem 1 of condition:enter image description here

try this:

;with cte as( select distinct     crs.courseid,     crs.coursename,     crs.coursedescription,     (select coursegroupname coursegroup cgrp       cgrp.coursegroupid = crs.coursegroupid) category      courses crs  inner join      courserequests creq on crs.courseid = creq.courseid     crs.coursename <> '''')  select *, (select count(courseid) cte) recordcounts cte 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -