By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,358 Members | 2,967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,358 IT Pros & Developers. It's quick & easy.

Update query not working in SQL Server

P: 30
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.



Expand|Select|Wrap|Line Numbers
  1.     UPDATE ed_tblFiles
  3.         SET CurrentStep =    CASE RIGHT(fu.OriginalFileName,3)
  4.                                 WHEN 'pgp' THEN 'PUNENCRYPT'
  5.                                 ELSE 'UNENCRYPT'
  7.     FROM ed_tblFiles fu
  9.     WHERE fu.FileID IN(
  11.         SELECT f.FileID
  12.         FROM ed_tblFiles f
  13.         INNER JOIN ed_tblPayorsMain p ON f.PayorID = p.PayorID
  14.         INNER JOIN ed_tblPayorsFileNameHandling fnh ON fnh.PayorID = p.PayorID
  15.         WHERE f.OriginalFileName LIKE fnh.FileNamePart + '%' AND
  16.         fnh.FileAction = 'PROCESS' AND f.CurrentStep = 'PCLSFLNAME')
I keep getting the error:

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

I've also tried the code without using a FROM clause as well.
May 15 '08 #1
Share this Question
Share on Google+
2 Replies

P: 30
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?

May 15 '08 #2

Expert 100+
P: 1,134
And whats even more annoying is how long it can take to find those simple mistakes
May 16 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.