SQL Management Studio 2008 does not like '|' Vertical Bar

Posted on 2012-08-30
Last Modified: 2012-09-17
Any quick fix?

Update pxdta.f4301 set phvr01='' where phdcto|phdoco|phkcoo in (select pddcto|pddoco|pdkcoo from pxdta.f4311 where pdlnty='JP')

Question by:Tom Winslow
    LVL 22

    Expert Comment

    put brackets ([ ]) or single quotes (') around the field names
    Update pxdta.f4301 set phvr01='' where [phdcto|phdoco|phkcoo] in (select [pddcto|pddoco|pdkcoo] from pxdta.f4311 where pdlnty='JP')

    Open in new window

    LVL 16

    Expert Comment

    You're trying to use a bit-wise OR function, aren't you?
    A "where" clause is normally expressed like this:

    where identifier_1 operation identifier_2

    where FieldName = OtherFieldName
    where FieldName in (select field from table)

    Your expression "phdcto|phdoco|phkco" may reduce to a value, but not an identifier.
    LVL 142

    Accepted Solution

    I think you want to do this:

    Update pxdta.f4301 t  
      set phvr01='' 
    where exists
      (select null from pxdta.f4311 o 
       where o.pdlnty='JP'
          and o.phdcto = t.phdcto
          and o.phdoco = t.phdoco
           and o.phkcoo = t.phkcoo)

    Open in new window


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now