473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to rectify this error

375 256MB
Hi,

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
  1. CREATE
  2.  procedure [dbo].[GeofenceByCustomer]
  3. @regno nvarchar(50),
  4. @frmdate nvarchar(50),
  5. @todate nvarchar(50),
  6. @Geofence nvarchar(50),
  7. @interval int,
  8. @userid nvarchar(50)
  9. as
  10. begin
  11. declare @val int
  12. Declare @strSql as nvarchar(3000)
  13. Select @val=count(*) from basestation where superuserid=@userid and
  14. base_station_name=@Geofence
  15.  
  16. --if(@val=0)
  17. begin
  18.         create table #templ(registrationno nvarchar(50),basestation
  19. nvarchar(50),entry_time datetime,exit_time datetime,duration
  20. int)
  21.         select @strSql='
  22.         insert into #templ(registrationno,basestation,entry_time,exit_time,duration)
  23.         select
  24. registrationno,basestation,entry_time,exit_time,datediff(mi,entry_time,exit_time)
  25. as duration from store_geofence where  entry_time>'+@frmdate+' and
  26. exit_time<'+@todate+' and datediff(mi,entry_time,exit_time)>'+@interval+'
  27. and basestation in ('+@Geofence+')  order by entry_time,registrationno'
  28.         execute (@strSql)
  29.         print @strSql
  30.         select * from #templ
  31.         drop table #templ
  32. end
  33.  
  34. end
  35. GO
  36.  
I should specify the duration in int to take affect

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
Apr 13 '08 #1
1 1182
Delerna
1,134 Expert 1GB
I think the error is actually comming from the date comparison.
There should be singe quotes around them
like this

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>'2008-01-01' and
exit_time<'2008-01-01' and datediff(mi,entry_time,exit_time)> etc

As they are i think they are being read as 1 divided by 1 divided by 2008
when the query sting is executed.



Note, there won't be any entry_time that is both less than and greater than 2008-01-01
Apr 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jason Clark | last post by:
IE says there is a page error. How to rectify? www.beamlmheavyhitter.com Jason
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
3
by: srikanth123456 | last post by:
hi when i am compiling my serial port programmming on windows environment i got a error called "unable to include the header file rs_lib.h. #include"rs_lib.h"
1
by: karthi84 | last post by:
hi, when i tried to open a new excel spread sheet from my web form i got this access denied page. can any one help me in solving this problem. Server Error in '/sk/ContractInvoice'...
2
by: anuparvathy | last post by:
Hi i wanted to resize my cell width of each cell in the grid view.i gave the following code: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { ...
1
by: Nithya Kalyani | last post by:
Hi Expert, I m a student, can any one help me in finding the answer of below one. The C programs given below contain errors, rectify them as needed. a) void main() { char linebuf; char...
1
by: keerthikarani | last post by:
hi, I m using the following code in vb.net, but it shows me some error, can u explain why this error occurs and how to rectify it, but the following code works fine in vb Private Declare...
3
by: sreegans | last post by:
Hi.. i appended 4 to 5 records, after that overflow error had occured while executing the sql query in vb.... Pl guide me how to solve this? Sree...
9
by: ahilar12 | last post by:
1. <head> 2. <script type="text/javascript"> 3. </script> 4. </head> 5. <body> 6. <form> 7. <select name="team" id="mylist" > 8. <option></option> 9....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.