[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

syntax error

Posted on 2007-10-08
4
Medium Priority
?
210 Views
Last Modified: 2010-03-20
I have this Query in a store proc that is giving error: Msg 102, Level 15, State 1, Procedure TabGet, Line 370
Incorrect syntax near '+'.

Can some body point what is worng with this.
Thanks in advance.


SET @Categories =
                 (SELECT COUNT(*)
                  FROM (
                        SELECT  DISTINCT sn.CategoryID   AS CategoryID,
                                srvd.VersionStatus
                        --INTO #CatCount
                        FROM  SiteNavigation sn  
                        JOIN  StandardRulesOfVersionDisplay_Category (@UserID, @CategoryList) srvd
                          ON  sn.CategoryID  = srvd.CategoryID
                        JOIN  CategoryVersion cv      
                          ON  cv.CategoryID = sn.CategoryID
                         AND  cv.SiteLangID = srvd.TopFBSiteLangID
                        JOIN  #tmpChildVersion tcv
                          ON  cv.CategoryID = tcv.CategoryID
                         AND  cv.SiteLangID = tcv.SiteLangID
                         AND  cv.version    = tcv.Version
                       WHERE  sn.ParentCategoryID = @TabCounter_ObjectID
                         AND  srvd.SiteLangID = @TabCounter_SiteLangID
                         AND  sn.SiteNavigationVersionID = @LatestPublished_SiteNavigationVersionID
                     ---Following criteria is a hack
                         AND  ((@TabCounter_SiteLangID = 1)
                          OR
                         (@TabCounter_SiteLangID <> 1
                          AND (srvd.TopFBSiteLangID = @TabCounter_SiteLangID OR srvd.FallBackEnabled = 1))                        
                        )
           
                           +
                           
                            (SELECT COUNT(*)
                             FROM SiteNavigation SN
                             WHERE SN.CategoryID = @TabCounter_ObjectID
                               AND SN.SiteNavigationVersionID = @LatestPublished_SiteNavigationVersionID
                               AND SN.IsActive = 'Y'
                               AND SN.ParentCategoryID IS NOT NULL)

0
Comment
Question by:SA4
4 Comments
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 20037346
Looks like you are missing a close Paren right before the + sign.
0
 
LVL 35

Expert Comment

by:David Todd
ID: 20038542
Hi,

My count is that there are two right parenthasis missing.

Regards
  David
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 20038635
SET @Categories =
                 (SELECT COUNT(*)
                  FROM (
                        SELECT  DISTINCT sn.CategoryID   AS CategoryID,
                                srvd.VersionStatus
                        --INTO #CatCount
                        FROM  SiteNavigation sn  
                        JOIN  StandardRulesOfVersionDisplay_Category (@UserID, @CategoryList) srvd
                          ON  sn.CategoryID  = srvd.CategoryID
                        JOIN  CategoryVersion cv      
                          ON  cv.CategoryID = sn.CategoryID
                         AND  cv.SiteLangID = srvd.TopFBSiteLangID
                        JOIN  #tmpChildVersion tcv
                          ON  cv.CategoryID = tcv.CategoryID
                         AND  cv.SiteLangID = tcv.SiteLangID
                         AND  cv.version    = tcv.Version
                       WHERE  sn.ParentCategoryID = @TabCounter_ObjectID
                         AND  srvd.SiteLangID = @TabCounter_SiteLangID
                         AND  sn.SiteNavigationVersionID = @LatestPublished_SiteNavigationVersionID
                     ---Following criteria is a hack
                         AND  ((@TabCounter_SiteLangID = 1)
                          OR
                         (@TabCounter_SiteLangID <> 1
                          AND (srvd.TopFBSiteLangID = @TabCounter_SiteLangID OR srvd.FallBackEnabled = 1))                        
                        )
                    ))   ---- here is the parenthesis missing, AFAIKS
                           +
                           
                            (SELECT COUNT(*)
                             FROM SiteNavigation SN
                             WHERE SN.CategoryID = @TabCounter_ObjectID
                               AND SN.SiteNavigationVersionID = @LatestPublished_SiteNavigationVersionID
                               AND SN.IsActive = 'Y'
                               AND SN.ParentCategoryID IS NOT NULL)
0
 

Author Comment

by:SA4
ID: 20042377
Thanks for help everyone, but I fixed it myself.

SET @Categories =
                 (SELECT COUNT(*)
                    FROM (
                        SELECT  DISTINCT sn.CategoryID   AS CategoryID,
                                srvd.VersionStatus
                        FROM  SiteNavigation sn  
                        JOIN  StandardRulesOfVersionDisplay_Category (@UserID, @CategoryList) srvd
                          ON  sn.CategoryID  = srvd.CategoryID
                        JOIN  CategoryVersion cv      
                          ON  cv.CategoryID = sn.CategoryID
                         AND  cv.SiteLangID = srvd.TopFBSiteLangID
                        JOIN  #tmpChildVersion tcv
                          ON  cv.CategoryID = tcv.CategoryID
                         AND  cv.SiteLangID = tcv.SiteLangID
                         AND  cv.version    = tcv.Version
                       WHERE  sn.ParentCategoryID = @TabCounter_ObjectID
                         AND  srvd.SiteLangID = @TabCounter_SiteLangID
                         AND  sn.SiteNavigationVersionID = @LatestPublished_SiteNavigationVersionID
                     ---Following criteria is a hack
                         AND  ((@TabCounter_SiteLangID = 1)
                          OR
                              (@TabCounter_SiteLangID <> 1
                         AND (srvd.TopFBSiteLangID = @TabCounter_SiteLangID OR srvd.FallBackEnabled = 1))))    AS ChildCount  -- <----------
                )
              + (SELECT COUNT(*)
                   FROM SiteNavigation SN
                  WHERE SN.CategoryID = @TabCounter_ObjectID
                    AND SN.SiteNavigationVersionID = @LatestPublished_SiteNavigationVersionID
                    AND SN.IsActive = 'Y'
                    AND SN.ParentCategoryID IS NOT NULL)
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard 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.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

868 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