If then in sql string

Posted on 2010-01-06
Last Modified: 2012-05-08
I am trying to write an sql statement and I know Im wrong below.

Essentially, if tblRegistration.Overage = 3, then AttendanceGrid Set X = 'X'
and  if tblRegistration.Overage is not 3, then AttendanceGrid Set X = ' '

How do I write that correctly below
Update AttendanceGrid Set X = 'X'

FROM tblRegistration INNER JOIN AttendanceGrid  on 

and tblRegistration.Overage = 3


Update AttendanceGrid Set X = ''

FROM tblRegistration INNER JOIN AttendanceGrid  on 

and tblRegistration.Overage < 3

Open in new window

Question by:al4629740
    1 Comment
    LVL 75

    Accepted Solution

    Update AttendanceGrid Set X = case when tblRegistration.Overage = 3 THEN  'X' else '' end
    FROM tblRegistration INNER JOIN AttendanceGrid  on

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 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

    13 Experts available now in Live!

    Get 1:1 Help Now