473,686 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to rectify this error

375 Contributor

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
  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
  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
  34. end
  35. GO
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)
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

Apr 13 '08 #1
1 1192
1,134 Recognized Expert Top Contributor
I think the error is actually comming from the date comparison.
There should be singe quotes around them
like this

insert into #templ(registra tionno,basestat ion,entry_time, exit_ time,duration)
registrationno, basestation,ent ry_time,exit_ti me,da tediff(mi,entry _time,exit_time )
as duration from store_geofence where entry_time>'200 8-01-01' and
exit_time<'2008-01-01' and datediff(mi,ent ry_time,exit_ti me)> 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

by: Jason Clark | last post by:
IE says there is a page error. How to rectify? www.beamlmheavyhitter.com Jason
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
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"
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' Application. Access is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
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) { e.Row.Cells.Width = new Unit("25px"); } But i got the error as "The name 'i' does not exist in the current context.
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 *lines; int i;
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 Function SQLDataSources Lib "odbc32.dll" _ (ByVal hEnv As Long, _ ByVal fDirection As Integer, _ ByVal szDSN As String, _ ByVal cbDSNMax As Integer, _ ByVal pcbDSN As Integer, _
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...
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. <option>north</option> 10. <option>south</option>
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.