SQL Query Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie19
    New Member
    • Jun 2007
    • 122

    #1

    SQL Query Error

    When I run this query in my sql query prompt, it comes out with the correct results, but when I but it into the VBA prompt for my excel program, it doesn't display the correct results.

    Any ideas?
    [code=mysql]
    SELECT dbo.Defects.Def ectId, dbo.Defects.Nam e, dbo.WorkflowSte ps.StepName, dbo.PriorityTyp es.Name AS PriorityName, dbo.SeverityTyp es.Name AS Severity, dbo.Defects.Bui ldNumber, dbo.DefectCusto mFields.Custom_ 86 AS TargetBuildNumb er, dbo.Defects.Bui ldNumberOfFix, CONVERT(varchar (20), dbo.Users.First Name) + ' ' + CONVERT(varchar (20), dbo.Users.LastN ame) as Creator, CONVERT(varchar (20), Users_1.FirstNa me) + ' ' + CONVERT(varchar (20), Users_1.LastNam e) AS AssignedUser, dbo.Projects.Na me AS ProjectName

    FROM dbo.Projects INNER JOIN
    dbo.Defects ON dbo.Projects.Pr ojectId = dbo.Defects.Pro jectId INNER JOIN
    dbo.Users ON dbo.Defects.Cre atorId = dbo.Users.UserI d INNER Join dbo.PriorityTyp es ON dbo.Defects.Pri orityTypeId = dbo.PriorityTyp es.PriorityType Id INNER JOIN
    dbo.SeverityTyp es ON dbo.Defects.Sev erityTypeId = dbo.SeverityTyp es.SeverityType Id INNER JOIN
    dbo.StatusTypes ON dbo.Defects.Sta tusTypeId = dbo.StatusTypes .StatusTypeId INNER JOIN
    dbo.WorkflowSte ps ON dbo.Defects.Wor kflowStepId = dbo.WorkflowSte ps.WorkflowStep Id INNER JOIN
    dbo.DefectCusto mFields ON dbo.Defects.Def ectId = dbo.DefectCusto mFields.DefectI d LEFT OUTER JOIN
    dbo.Users AS Users_1 ON dbo.Defects.Ass ignedToId = Users_1.UserId

    WHERE (dbo.Defects.St atusTypeId IN (9, 10, 1, 11, 2, 3, 8)) AND (dbo.Projects.P rojectId IN (" + projIds + ")) AND(dbo.Defects .DefectId NOT IN

    (SELECT dbo.defects.Def ectId
    FROM dbo.Defects AS Defects_1
    WHERE (dbo.defects.La stUpdatedDateTi me < '" + DefectClosedFil terDate + "') AND (dbo.defects.St atusTypeId = 8) AND (Defects.Projec tId IN (" + projIds + "))))

    ORDER BY dbo.WorkflowSte ps.StepName, dbo.PriorityTyp es.Name, dbo.Defects.Def ectId DESC
    [/code]
    Last edited by Atli; Jul 19 '07, 03:58 PM. Reason: Added code tags
  • Newbie19
    New Member
    • Jun 2007
    • 122

    #2
    I figured the issue out, I didn't have my variables declared.

    Comment

    Working...