title: Error: Incorrect syntax near (database name)
body: <p>hi I am getting this error in my Java program. Here  is my query. It is working good in SQL server. but getting </p>
  
  <blockquote>
    <p>Error: Incorrect syntax near 'WebApp'.</p>
  </blockquote>
  
  <pre><code>private static final String SERVICES = 
          "SELECT  s.Service_ID  "
              + ",s.[Location_ID]  "
              + ",COALESCE(st.[Service_Type_Name],s.[Service_Name]) AS Service_name "
              + ",st.Service_Type_Name "
              + " FROM    [WebApp].[dbo].[Services]  s join [WebApp].[dbo].[ServiceTypes]  st on s.Service_Type=st.Service_Type_ID "
              + " join WebApp.dbo.Locations l on s.Location_ID=l.Location_ID " 
              + " where s.Deleted=0 " 
              + " ORDER BY Location_ID ";
  </code></pre>
  
  <p>and here is my method it is working fine on ms sql server 2008</p>
  
  <pre><code>    public List&lt;MAServiceVO&gt; getAddServices() throws CoopCRSAPIException {
          ArrayList&lt;MAServiceVO&gt; results = new ArrayList&lt;MAServiceVO&gt;();
          MAServiceVO maServiceVO = null;
          log.debug("==========IN VendorDAOimpl.java (service)===========");
          //int serviceID = 0;
          //int prevServiceID = 0;
          try {
              conn = MSSQLDAOFactory.createConnection();
              stmt  = conn.prepareStatement(SERVICES);
  //          stmt.setTimestamp(1, startDate);
  //          stmt.setTimestamp(2, endDate);
  
              stmt.execute();
              rs = stmt.getResultSet();
  
              while (rs.next()) {
  
                      // create new service
                      maServiceVO = new MAServiceVO();
                      // set service fields
                      maServiceVO.setServiceID(rs.getInt("Service_ID"));
                      maServiceVO.setLocationID(rs.getInt("Location_ID"));                    
                      maServiceVO.setServiceName(rs.getString("Service_Name"));
                      maServiceVO.setServiceType(rs.getString("Service_Type_Name"));
                      log.debug("==========done with VendorDAOimpl.java (service)===========");
  
                  } 
  
          } catch (SQLException e) {
              log.debug(e.getMessage());
              throw new CoopCRSAPIException(e.getMessage(), " VendorDAOimpl", "getAddServices", 500);
          } finally {
              closeConnections("getAddServices");
          }
          log.debug("&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;");
          log.debug("==========finsh===========");
          return results;
  
      }
  </code></pre>