Issues from converting from mySQL to msSQL

We have a query (in ColdFusion) that used to back to a mySQL server.

   select LENGTH(Subchapter_Article1) - (LENGTH(REPLACE(Subchapter_Article1,"building staff","")) ) as D_Count,Subchapter_Article1,Subchapter_Title,Part_ID,Chapter_ID,Subchapter_ID,Publish_Subchapter_Article1 from subchapters4 where Publish_Subchapter_Article1 like "%building staff%" and Part_ID != '5' and Publish_Subchapter_Article1 !='' and chapter_id in (select chapter_id from chapters4 where publish_status = 'y') ORDER BY D_Count DESC

Open in new window


when we change it to LEN instead of LENGTH

   select LEN(Subchapter_Article1) - (LEN(REPLACE(Subchapter_Article1,"building staff","")) ) as D_Count,Subchapter_Article1,Subchapter_Title,Part_ID,Chapter_ID,Subchapter_ID,Publish_Subchapter_Article1 from subchapters4 where Publish_Subchapter_Article1 like "%building staff%" and Part_ID != '5' and Publish_Subchapter_Article1 !='' and chapter_id in (select chapter_id from chapters4 where publish_status = 'y') ORDER BY D_Count DESC

Open in new window


I get the following error:

An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name.
digitalwiseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_agx_Commented:
EDIT: Wow... if I'm not mistaken, that's a very cryptic way of saying you need to use single quotes around the string literals, instead of double quotes ;-)

Just change the quotes and it works without a hitch.

SELECT
       LEN(Subchapter_Article1) - 
       (
           LEN(REPLACE(Subchapter_Article1,'building staff','')) 
       ) 
       AS D_Count
FROM  subchapters4 
ORDER BY D_Count DESC

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
digitalwiseAuthor Commented:
Thanks - as usual for your help!   I would be great if I could hire you for some of these projects
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.