473,386 Members | 1,644 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,386 software developers and data experts.

SQL Enterprise not updating table

31
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, '-', '')
Sep 14 '07 #1
16 2147
davef
98
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.
Sep 14 '07 #2
Joell
31
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?
Sep 14 '07 #3
davef
98
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.
Sep 14 '07 #4
Joell
31
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?
Sep 14 '07 #5
davef
98
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.
Sep 14 '07 #6
Joell
31
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.
Sep 14 '07 #7
Joell
31
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?
Sep 14 '07 #8
ck9663
2,878 Expert 2GB
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
Sep 14 '07 #9
Joell
31
c_quote is a datetime data type in my database. What else can I try?
Sep 14 '07 #10
ck9663
2,878 Expert 2GB
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)
Sep 14 '07 #11
Joell
31
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.
Sep 17 '07 #12
ck9663
2,878 Expert 2GB
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?
Sep 17 '07 #13
Joell
31
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.
Sep 17 '07 #14
ck9663
2,878 Expert 2GB
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.
Sep 18 '07 #15
Joell
31
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!
Sep 18 '07 #16
Dosth
1
try this

convert(varchar(10),c_quote,101) >= convert(varchar(10),getdate()-1,101)

Thanks
Dosth
Nov 26 '07 #17

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

Similar topics

1
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...
1
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...
4
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...
0
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. ...
5
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...
10
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)...
4
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...
0
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. ...
2
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...
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
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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.