Hi Guys,
I have the following code in the Enterprise Job Scheduler and it runs successfully but the table is not updated. I first put it into a stored procedure but when they did not work, I put just the code to insert the records directly into the scheduler. Its supposed to update nightly at 5am, but when I run my crystal report the next day, nothing in the table was updated. Please help!
This is SQL script. I do not know any other coding practices. - JO insert into NewCustomers
select cust.c_id_alpha Location_ID, cust.c_name Location_name,
substring (CUST.c_name, CHARINDEX('#', CUST.c_name)+1, ((len(CUST.c_name) - (len(CUST.c_Name) - CHARINDEX('#', CUST.c_name))))) Store_no,
C_ADDRNUM1, C_ADDR1, C_ADDR2,
C_CITY, C_STATE, C_ZIP, C_PHO, C_FAX Cust_Fax_No, c_pcont Cust_Contact, null, cmpy.company
FROM cust inner join udef_active_cstat ud on cust.c_cstat = ud.unique_id
left join dbo.ups_keepers k on cust.c_id = k.c_id
inner join cmpy on cust.b_bill_co = cmpy.cmpy_id
where right(cust.c_id_alpha, 3) <> '001'
and b_bill_co not in (30,2,26,29,4)
and c_quote >= getdate()-1
update NewCustomers
set Standard_Instructions = rxrf.comment
FROM cust inner join udef_active_cstat ud on cust.c_cstat = ud.unique_id
left join dbo.ups_keepers k on cust.c_id = k.c_id
inner join rxrf on cust.c_id = rxrf.c_id
inner join cmpy on cust.b_bill_co = cmpy.cmpy_id
inner join NewCustomers L on L.Location_id = cust.c_id_alpha
where right(cust.c_id_alpha, 3) <> '001'
and b_bill_co not in (30,2,26,29,4)
and c_quote >= getdate()-1
update NewCustomers set c_pho = replace(c_pho, '-', '')
update NewCustomers set c_pho = replace(c_pho, ')', '')
update NewCustomers set c_pho = replace(c_pho, '(', '')
update NewCustomers set c_pho = replace(c_pho, ' ', '')
update NewCustomers set c_zip = replace(c_zip, '-', '')
update NewCustomers set cust_FAX_no = replace(cust_fax_no, '-', '') 16 2147
If you're getting no error, one can assume that your update query affects no rows because no matches are found. Check whether your select query returns any rows first.
ok its the getdate() function. I am trying to pull at 5am the previous day's new customers and add them to this table. When I put in yesterdays date, I get them when I put in getdate() -1 I dont? Am I not using the correct date function?
getdate() - 1 <--- is this not correct?
ok its the getdate() function. I am trying to pull at 5am the previous day's new customers and add them to this table. When I put in yesterdays date, I get them when I put in getdate() -1 I dont? Am I not using the correct date function?
getdate() - 1 <--- is this not correct?
The time on the server might be set to GMT hence the offset. Make sure you accomodate for it.
That would only 1 hour. We dont have people entering data until after 8am in the morning. Actually we only have one person adding in new customers. Could it be something else?
That would only 1 hour. We dont have people entering data until after 8am in the morning. Actually we only have one person adding in new customers. Could it be something else?
Print getdate()-1 on the server and place it in the query. See if it fetches the dataset.
the clock on that server is the exact time. It is correct. But, my query is still not pulling early the morning the day before data. I dont understand it. If I pull it now with an actual date it works fine.
The is what I mean:
Select c_id_alpha, c_name, c_quote, getdate() from cust where c_quote >= '09/14/2007'
returns 9 rows
Select c_id_alpha, c_name, c_quote, getdate() from cust where c_quote >= getdate()
returns 0 rows
how can this be?
The is what I mean:
Select c_id_alpha, c_name, c_quote, getdate() from cust where c_quote >= '09/14/2007'
returns 9 rows
Select c_id_alpha, c_name, c_quote, getdate() from cust where c_quote >= getdate()
returns 0 rows
how can this be?
if your c_quote is string, and it's not in proper/expected date format, the explicit conversation could be failing, hence the false condition on your where. if it's a string, use a convert or a cast function, then compare
c_quote is a datetime data type in my database. What else can I try?
c_quote is a datetime data type in my database. What else can I try?
how many rows will this query returns:
Select c_id_alpha, c_name, c_quote, getdate() from cust where c_quote >= cast('09/14/2007' as datetime)
That query with the cast returns the same rows as just using the date field. I need to use the getdate() though. I just dont understand why it will not bring back the same results.
That query with the cast returns the same rows as just using the date field. I need to use the getdate() though. I just dont understand why it will not bring back the same results.
would you mind posting some of the data/rows?
would you mind posting some of the data/rows?
Select c_id_alpha Acct_no, c_quote, getdate() Getdate_column from cust where c_quote >= '09/14/2007'
406765 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406789 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406784 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406786 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406787 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406788 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406790 2007-09-17 00:00:00.000 2007-09-17 15:43:45.613
It works fine this way.... but when I use the getdate() function, I get 0 rows.
Select c_id_alpha Acct_no, c_quote, getdate() Getdate_column from cust where c_quote >= '09/14/2007'
406765 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406789 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406784 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406786 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406787 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406788 2007-09-14 00:00:00.000 2007-09-17 15:43:45.613
406790 2007-09-17 00:00:00.000 2007-09-17 15:43:45.613
It works fine this way.... but when I use the getdate() function, I get 0 rows.
because your c_quote are all 2007-09-14 dates and getdate() is 2007-09-17. getdate(), in this example, is greater than 2007-09-17, hence no result set are returned.
because your c_quote are all 2007-09-14 dates and getdate() is 2007-09-17. getdate(), in this example, is greater than 2007-09-17, hence no result set are returned.
I was using c_quote >= getdate() -1
The query is supposed to run at 5am so I do not know if it will work correctly until tomorrow but I think this might work:
c_quote >= convert(datetime,convert(varchar,getdate(),101)) -1
Thanks for your efforts!
try this
convert(varchar(10),c_quote,101) >= convert(varchar(10),getdate()-1,101)
Thanks
Dosth
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mikew |
last post by:
I am working at a company that has been using MS SQL Server, and we are going to be switching over to postgresql next week. (Getting off of Windows will be a relief!)
I am very familiar with SQL...
|
by: srihari |
last post by:
Hai,
I am trying to install IBM DB2 8.1 on Red Hat linux 8.0. My
machine is Intel XEON 64bit. The installation went well except for the
creation of tools catalog. When I tried to install the tools...
|
by: dp |
last post by:
Anyone have any reason why I can open a table in SQL Enterprise manager,
return all rows, and edit the record set, but when I go in through an ADP,
connect to the database, and try to edit the same...
|
by: Mythran |
last post by:
I downloaded the patterns and practices enterprise library and found that it
is much different for the Data library that I am used to (SqlHelper)..It's
not just an update but a total rewrite. ...
|
by: JesseJr |
last post by:
I recently installed Microsoft's Visual C++ 6.0 Enterprise
Edition(1985-1999) on my antiquated AMD K-6 2/300 with 160 Mb of SDRAM (PC66)
with a 120 Gb 8mb mem Seagate Hard Drive and an NVidia...
|
by: jaYPee |
last post by:
does anyone experienced slowness when updating a dataset using
AcceptChanges?
when calling this code it takes many seconds to update the database
SqlDataAdapter1.Update(DsStudentCourse1)...
|
by: Geoff |
last post by:
Hi
I'm hoping somebody can help me with the following problem that has occurred
to me.
Suppose I have two tables in an SQL Server database. Let's call these tables
A and B. Assume that A has...
|
by: Dharmen Patel |
last post by:
I am using Enterprise Library 2006 , Data Access Application Blocks.
1. I am connecting to Oracle 9i database using DAAB.
2. I retrieve a dataset using the following code in VB.NET. ...
|
by: srinivasan.shanmugapillai |
last post by:
Hi,
I'm running a VB.NET windows applicatrion that is using the enterprise
services transactions.
While running this application without enterprise services support, a
connection is...
|
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$) {
}
...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
| |