Solved

Assistance with an update statement that requires inner join

Posted on 2013-12-19
3
526 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

688 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