Update query not working in SQL Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zachster17
    New Member
    • Dec 2007
    • 30

    Update query not working in SQL Server

    Hello everyone,

    I'm having difficult getting an update query to work. What I'm doing is search a table with filenames against another table that has filename wildcards that search against the filenames--if a match is found then it updates the status of the files.

    Code is below; let me know if I can clarify anything for you.

    Thanks,

    Zach

    Code:
    	UPDATE ed_tblFiles
    	
    		SET CurrentStep =	CASE RIGHT(fu.OriginalFileName,3)
    								WHEN 'pgp' THEN 'PUNENCRYPT'
    								ELSE 'UNENCRYPT'
    
    	FROM ed_tblFiles fu
    
    	WHERE fu.FileID IN(
    
    		SELECT f.FileID
    		FROM ed_tblFiles f
    		INNER JOIN ed_tblPayorsMain p ON f.PayorID = p.PayorID
    		INNER JOIN ed_tblPayorsFileNameHandling fnh ON fnh.PayorID = p.PayorID
    		WHERE f.OriginalFileName LIKE fnh.FileNamePart + '%' AND
    		fnh.FileAction = 'PROCESS' AND f.CurrentStep = 'PCLSFLNAME')
    I keep getting the error:

    Msg 156, Level 15, State 1, Procedure ed_proClassifyF iles, Line 17
    Incorrect syntax near the keyword 'FROM'.

    I've also tried the code without using a FROM clause as well.
  • zachster17
    New Member
    • Dec 2007
    • 30

    #2
    Hey guys,

    I solved my own problem. I left the END out of the CASE clause (duh!).

    Isn't it annoying when you always make the same mistake?

    Zach

    Comment

    • Delerna
      Recognized Expert Top Contributor
      • Jan 2008
      • 1134

      #3
      And whats even more annoying is how long it can take to find those simple mistakes

      Comment

      Working...