We help IT Professionals succeed at work.

Debug "Incorrect syntax near 'FileType'Col"

39 Views
Last Modified: 2016-02-23
The first section works fine, but after that, I get an error in this section below. The equals sign looks like it's highlighted. I need to add many more SET statements. How do i avoid the error?

set [FileTypeCol] = 'File Type2'

use [database]

update table
set [FileTypeCol] = 'File Type1'
from table
where [FileTitle] like '%FileType1%'
   or [Content Title] like '%file-type1%'
   or [Content Title] like '%file Type 1%'
   or [Content Title] like '%File_Type1%'

set [FileTypeCol] = 'File Type2'
from table
where [FileTitle] like '%filetyp2%'
   or [Content Title] like '%file_type2%'

set [FileType] = 'File Type 3'
from table
where [FileTypeCol] like '%filetype3%'
   or [Content Title] like '%FileType3%'

Open in new window

Comment
Watch Question

SQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Olaf DoschkeSoftware Developer
CERTIFIED EXPERT

Commented:
Even line 1 is missing the UPDATE TABLE. There is no such thing as a set command for fields, you can only set variables like this, SET field=value always is the clause of an SQL-UPDATE first specifying the table to update.

Bye, Olaf.
Jim HornSQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015

Commented:
>Debug "Incorrect syntax near 'FileType'Col"
>How do i avoid the error?
Also in the future when you copy-paste a code block where the error occured, tell us the line number of the error, making sure that it translates to the EE code block numbers.

Author

Commented:
I believe there was a copy-paste error when the admin added my code to the code block. My original code goes from line 3 to line 21. That said, thank you for the feedback. Lots of helpful information. Jim, the code worked after I made the changes you recommended. Thanks!
Jim HornSQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015

Commented:
Thanks for the grade.  Good luck with your code.  -Jim
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.