Hi,
I want to retrieve the values from store_geofence table where the timeduration exceeds certain interval
the procedure is as below[code=sql]
CREATE
procedure [dbo].[GeofenceByCusto mer]
@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=@us erid and
base_station_na me=@Geofence
--if(@val=0)
begin
create table #templ(registra tionno nvarchar(50),ba sestation
nvarchar(50),en try_time datetime,exit_t ime datetime,durati on
int)
select @strSql='
insert into #templ(registra tionno,basestat ion,entry_time, exit_time,durat ion)
select
registrationno, basestation,ent ry_time,exit_ti me,datediff(mi, entry_time,exit _time)
as duration from store_geofence where entry_time>'+@f rmdate+' and
exit_time<'+@to date+' and datediff(mi,ent ry_time,exit_ti me)>'+@interval +'
and basestation in ('+@Geofence+') order by entry_time,regi strationno'
execute (@strSql)
print @strSql
select * from #templ
drop table #templ
end
end
GO
[/code]
I should specify the duration in int to take affect
datediff(mi,ent ry_time,exit_ti me)>'+@interval +'
but i do not know how to rewrite this path
i cannot put as
datediff(mi,ent ry_time,exit_ti me)>'+@interval +'
it returns an error
Syntax error converting the nvarchar value '
insert into #templ(registra tionno,basestat ion,entry_time, exit_time,durat ion)
select
registrationno, basestation,ent ry_time,exit_ti me,datediff(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,ent ry_time,exit_ti me)>' to a column of data type int.
How should i rewrite it
please help
regards
cmrhema
I want to retrieve the values from store_geofence table where the timeduration exceeds certain interval
the procedure is as below[code=sql]
CREATE
procedure [dbo].[GeofenceByCusto mer]
@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=@us erid and
base_station_na me=@Geofence
--if(@val=0)
begin
create table #templ(registra tionno nvarchar(50),ba sestation
nvarchar(50),en try_time datetime,exit_t ime datetime,durati on
int)
select @strSql='
insert into #templ(registra tionno,basestat ion,entry_time, exit_time,durat ion)
select
registrationno, basestation,ent ry_time,exit_ti me,datediff(mi, entry_time,exit _time)
as duration from store_geofence where entry_time>'+@f rmdate+' and
exit_time<'+@to date+' and datediff(mi,ent ry_time,exit_ti me)>'+@interval +'
and basestation in ('+@Geofence+') order by entry_time,regi strationno'
execute (@strSql)
print @strSql
select * from #templ
drop table #templ
end
end
GO
[/code]
I should specify the duration in int to take affect
datediff(mi,ent ry_time,exit_ti me)>'+@interval +'
but i do not know how to rewrite this path
i cannot put as
datediff(mi,ent ry_time,exit_ti me)>'+@interval +'
it returns an error
Syntax error converting the nvarchar value '
insert into #templ(registra tionno,basestat ion,entry_time, exit_time,durat ion)
select
registrationno, basestation,ent ry_time,exit_ti me,datediff(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,ent ry_time,exit_ti me)>' to a column of data type int.
How should i rewrite it
please help
regards
cmrhema
Comment