?
Solved

Assistance with an update statement that requires inner join

Posted on 2013-12-19
3
Medium Priority
?
530 Views
Last Modified: 2014-01-29
I am trying to use the update statement below. I receive an error. I am sure it's syntax.  

Here is the query as I originally run it:
UPDATE  a
SET a.startdate=b.proposed_start_date, 
        a.enddate=b.proposed_end_date
FROM    njobslstasks a INNER JOIN 
        lot_schedule_proposed_changes b ON a.PROGRESS_RECID_IDENT_ = b.progress_id
WHERE   b.bldrcode = 'jima'

Open in new window


Here is how the management studio inside of the query window modifies it:

UPDATE    a
SET              a.startdate = b.proposed_start_date, a.enddate = b.proposed_end_date
FROM         rems.njobslstasks AS a INNER JOIN
                      rems.lot_Schedule_proposed_changes AS b ON a.PROGRESS_RECID_IDENT_ = b.progress_id CROSS JOIN
                      a
WHERE     (b.bldrcode = 'jima')

Open in new window


I attached the error message as a screenshot
error.png
0
Comment
Question by:J C
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 2000 total points
ID: 39730158
do you get the error if you take out the 'CROSSJOIN a' ?
I don't know why it is being added but it seems to be in error.
Make sure you are using New Query option not Open Table option.

Same sort of problem here :

http://www.experts-exchange.com/Programming/Languages/.NET/Q_22640924.html
0
 

Author Comment

by:J C
ID: 39730223
jacko72,

Arg, I was not using the new query window and once I did it works. Can you tell me what I'd need to do to add the delete statement so that after the statement runs it deletes the records in that table? Thank you for your help
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 39730264
I think this will do it, please test before using :
UPDATE  a
SET a.startdate=b.proposed_start_date, 
        a.enddate=b.proposed_end_date
FROM    njobslstasks a INNER JOIN 
        lot_schedule_proposed_changes b ON a.PROGRESS_RECID_IDENT_ = b.progress_id
WHERE   b.bldrcode = 'jima' 
go
Delete b FROM njobslstasks a INNER JOIN
        lot_schedule_proposed_changes b ON a.PROGRESS_RECID_IDENT_ = b.progress_id
WHERE   b.bldrcode = 'jima' 
go

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question