Anyone tell me what is wrong with this?

Posted on 2008-11-10
Last Modified: 2012-05-05
I have a strored procedure which part of it is as below..
It keeps syaing incorrect syntax...
ANyone tell me what is wrong?

      insert into  Details  (FIeld naems etcc)
                      SELECT     FIeld Names etc
                  FROM Another_Details left outer join users on aother_details.officer_id = users.attendant_id
                                        Where ID = @KeyID and Registration_No >''
                  WHERE     (Users.Account_Disabled = '0')

Obviously field names is jst a summary of the fileds in the table..
its the WHERE     (Users.Account_Disabled = '0') bit which has caused the problem...
Question by:funkkube
    LVL 37

    Expert Comment

    did you try
    WHERE     (Users.Account_Disabled = 0)
    LVL 142

    Accepted Solution

    you have 2 times WHERE...
    also, the condition on the users table, as it is left joined, needs to be in the join itself.
    insert into  Details  (FIeld naems etcc)
    SELECT     FIeld Names etc
    FROM Another_Details 
    left outer join users 
      on aother_details.officer_id = users.attendant_id 
     and Users.Account_Disabled = '0'
    Where Another_Details.ID = @KeyID 
     and Another_Details.Registration_No >''

    Open in new window


    Author Comment

    super thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    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…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 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

    23 Experts available now in Live!

    Get 1:1 Help Now