Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Assistance with an update statement that requires inner join

Posted on 2013-12-19
3
Medium Priority
?
533 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

610 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