Click here to Skip to main content
15,907,392 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I try this sql query

SQL
Select tblRV.ID as ID, tblRV.Owner, tblRV.Regno,

(Select Count(*) as total from tblvv WHERE MID = tblRV.ID and Name <> '')

as total,tblRV.MA, tblRV.MS from tblReg inner join tblRV On tblReg.RID = tblRV.RID

WHERE tblReg.StartDate >= '2016-06-01 00:00:00' AND 
    tblReg.EndDate <= '2016-06-08 23:59:59' 
    and tblReg.Region = 'UK'
order by tblRV.Owner


this query return me 24 rows so when i create procedure then i exe store procedure like this

What I have tried:

SQL
grid_data 'UK' ,'2016-06-01 00:00:00', '2016-06-08 23:59:59'

sp

SQL
ALTER procedure [dbo].[grid_data]
@region varchar(50),
@fromdate datetime,
@todate datetime
as
 Select tblRV.ID as ID, tblRV.Owner, tblRV.Regno,

    (Select Count(*) as total from tblvv WHERE MID = tblRV.ID and Name <> '')

    as total,tblRV.MA, tblRV.MS from tblReg inner join tblRV On tblReg.RID = tblRV.RID

     
    order by tblRV.Owner

THIS SHOW ME 24913 records.
Posted
Updated 2-Aug-16 21:40pm
v4
Comments
OriginalGriff 25-Jul-16 1:47am    
Why are you passing parameters to your SP if you aren't using them?
Are you sure that 1) the SP looks exactly like that? 2) The DB is the same one for both queries?
super_user 25-Jul-16 3:03am    
problem solved
Suvendu Shekhar Giri 25-Jul-16 3:06am    
Share you answer and mark it as solution so that others can refer it.
super_user 25-Jul-16 5:32am    
i only add this line in sp WHERE tblReg.StartDate >= @startdate AND
tblReg.EndDate <= @enddate
and tblReg.Region = @region

1 solution

In Sp you did not use where condition WHERE tblReg.StartDate >= @fromdate AND
tblReg.EndDate <= @todate
and tblReg.Region =@region


Put it in Sp you will get your desired result.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900