I want to retrieve the values from store_geofence table where the timeduration exceeds certain interval
the procedure is as below
Expand|Select|Wrap|Line Numbers
- CREATE
- procedure [dbo].[GeofenceByCustomer]
- @regno nvarchar(50),
- @frmdate nvarchar(50),
- @todate nvarchar(50),
- @Geofence nvarchar(50),
- @interval int,
- @userid nvarchar(50)
- as
- begin
- declare @val int
- Declare @strSql as nvarchar(3000)
- Select @val=count(*) from basestation where superuserid=@userid and
- base_station_name=@Geofence
- --if(@val=0)
- begin
- create table #templ(registrationno nvarchar(50),basestation
- nvarchar(50),entry_time datetime,exit_time datetime,duration
- int)
- select @strSql='
- insert into #templ(registrationno,basestation,entry_time,exit_time,duration)
- select
- registrationno,basestation,entry_time,exit_time,datediff(mi,entry_time,exit_time)
- as duration from store_geofence where entry_time>'+@frmdate+' and
- exit_time<'+@todate+' and datediff(mi,entry_time,exit_time)>'+@interval+'
- and basestation in ('+@Geofence+') order by entry_time,registrationno'
- execute (@strSql)
- print @strSql
- select * from #templ
- drop table #templ
- end
- end
- GO
datediff(mi,entry_time,exit_time)>'+@interval+'
but i do not know how to rewrite this path
i cannot put as
datediff(mi,entry_time,exit_time)>'+@interval+'
it returns an error
Syntax error converting the nvarchar value '
insert into #templ(registrationno,basestation,entry_time,exit_ time,duration)
select
registrationno,basestation,entry_time,exit_time,da tediff(mi,entry_time,exit_time)
as duration from store_geofence where entry_time>01/01/2008 and
exit_time<01/01/2008 and datediff(mi,entry_time,exit_time)>' to a column of data type int.
How should i rewrite it
please help
regards
cmrhema