sql - Getting 0 rows returned on query -


so let me start basic table layout tables involved:

#zip_code_time_zone

+----+----------+-----------+ | id | zip_code | time_zone | +----+----------+-----------+ |  1 |    00544 |        -1 | |  2 |    00601 |        -3 | |  3 |    00602 |         0 | |  4 |    00603 |        -3 | |  5 |    00604 |         0 | +----+----------+-----------+ 

#pricing_record

+------+---------------+--------------------+ |  id  | location_code | service_center_zip | +------+---------------+--------------------+ | 7119 | tx725         |              79714 | | 7121 | tx734         |              75409 | | 7122 | tx737         |              78019 | | 7124 | tx742         |              75241 | | 7126 | tx751         |              77494 | +------+---------------+--------------------+ 

#transaction_record

+----+-----------------+------------------+--------------+--------------+ | id | truck_stop_code |   create_date    | gps_verified | central_time | +----+-----------------+------------------+--------------+--------------+ |  1 | ca428           | 05/01/2015 14:52 |            0 | null         | |  2 | ca343           | 05/01/2015 19:10 |            0 | null         | |  3 | ca223           | 05/01/2015 09:28 |            0 | null         | |  4 | ca721           | 05/01/2015 07:55 |            0 | null         | |  5 | mn336           | 05/01/2015 06:46 |            0 | null         | +----+-----------------+------------------+--------------+--------------+ 

when working on project issue noticed create_date column in transaction_record. needs converted central time, wrote update query, have been unable set central_time column. query below:

query

update t set t.central_time = dateadd(hour, z.time_zone,convert(datetime, t.create_date, 120)) eagle_devel.dbo.zip_code_time_zone z inner join eagle_devel.dbo.pricing_record p on z.zip_code = p.service_center_zip inner join eagle_devel.dbo.transaction_record t on t.truck_stop_code = p.location_code 

this when run query

(0 row(s) affected) 

notes

the time_zone column in #zip_code_time_zone not standard utc difference calculate central

i still working on speak, looking assistance see if else can fix faster myself.

try instead little changes, table updating should in from clause , adjust join accordingly

update t set t.central_time = dateadd(hour, z.time_zone,convert(datetime, t.create_date, 120)) eagle_devel.dbo.transaction_record t inner join eagle_devel.dbo.pricing_record p on t.truck_stop_code = p.location_code inner join eagle_devel.dbo.zip_code_time_zone z on z.zip_code = p.service_center_zip 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -