locked
syntax error missing operator in sql expression , please help RRS feed

  • Question

  • User160479614 posted

     

    "SELECT od.OrderID, SUM(CONVERT(money, (od.UnitPrice * " &_ 

    "   od.Quantity) * (1 - od.Discount) / 100) * 100) " &_

    "   AS Total, o.EmployeeID, o.OrderDate, " &_

    "   c.CompanyName" &vbcrlf&_

    "FROM [Order Details] od " &_

    "   INNER JOIN Orders o " &_

    "   ON od.OrderID = o.OrderID" &vbcrlf&_

    "   INNER JOIN Customers c " &_

    "   ON o.CustomerID = c.CustomerID" &vbcrlf&_

    "GROUP BY od.OrderID, o.EmployeeID, o.OrderDate, c.CompanyName"

    please help me in this sql statement and where is the error, thanks in advanced.

    Sunday, July 1, 2012 7:39 AM

Answers

  • User1954304945 posted

    Hi, you can write your SQL command to page, copy and run the sql command in Microsoft SQL Server Management. And then according to error message to modify the SQL command.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 2, 2012 10:05 PM

All replies

  • User337566521 posted

    If you are doing in C#

    use this way

    "SELECT od.OrderID, SUM(CONVERT(money, (od.UnitPrice * " +
    "od.Quantity) * (1 - od.Discount) / 100) * 100) " +
    "AS Total, o.EmployeeID, o.OrderDate, " +
    " c.CompanyName" +
    "FROM [Order Details] od " +
    " INNER JOIN Orders o " +
    " ON od.OrderID = o.OrderID" +
    " INNER JOIN Customers c " +
    " ON o.CustomerID = c.CustomerID" +
    "GROUP BY od.OrderID, o.EmployeeID, o.OrderDate, c.CompanyName";
    //string Patient_name = "Hello", Export_TO = "Hai", repType = "1" ;

    In Vb.net

    "SELECT od.OrderID, SUM(CONVERT(money, (od.UnitPrice * " & _
    "od.Quantity) * (1 - od.Discount) / 100) * 100) " & _
    "AS Total, o.EmployeeID, o.OrderDate, " & _
    " c.CompanyName" & _
    "FROM [Order Details] od " & _
    " INNER JOIN Orders o " & _
    " ON od.OrderID = o.OrderID" & _
    " INNER JOIN Customers c " & _
    " ON o.CustomerID = c.CustomerID" & _
    "GROUP BY od.OrderID, o.EmployeeID, o.OrderDate, c.CompanyName"

    There are gaps in each line so there were syntax errors

    Mark this as answer if it works for u.

    Sunday, July 1, 2012 8:23 AM
  • User1954304945 posted

    Hi, you can write your SQL command to page, copy and run the sql command in Microsoft SQL Server Management. And then according to error message to modify the SQL command.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 2, 2012 10:05 PM