Avatar of Calyx Teren
Calyx TerenFlag for United States of America asked on

Debug "Incorrect syntax near 'FileType'Col"

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

Microsoft SQL ServerMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
Jim Horn

8/22/2022 - Mon
Jim Horn

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Olaf Doschke

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 Horn

>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.
Calyx Teren

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!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Jim Horn

Thanks for the grade.  Good luck with your code.  -Jim