Results 1 to 5 of 5
  1. #1
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209

    Convert SQL Server Query to Access Query

    How would I run this SQL Server query in an Access Query?


    Code:
    Select a.employee_name, Count(b.employee_name)
    From dbo.info a
    Left Join dbo.Master b
    On b.employee_name = a.employee_name
    And b.sick_day Between '2013-03-01' And '2013-03-31'
    Group By a.employee_name

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    As a pass through query it can run as-is. In an Access query, you'd want # instead of ' as a delimiter for the dates, and you wouldn't want the dbo. before the table names.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    What do you mean a pass through query?

    This query when I attempt to run in access, tells me there is an error in my JOIN statement. Maybe that is what you meant as a pass through query.

    EDIT
    The actual error is JOIN expression not supported.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    I don't see a problem. Just tested and this ran fine (Access query against linked SQL Server tables):

    SELECT B.EmpNum, B.DocCert, A.EmpLastName
    FROM tblHRData A LEFT JOIN tblEmpDocCert B ON A.EmpNum = B.EmpNum

    Can you post your db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Sorry, a pass through query is one that has a connection string and it simply passes the SQL to the back end, in this case SQL Server. In that type of query, you would still use T-SQL.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. convert ms sql query to access sql query
    By jcgldr in forum Queries
    Replies: 11
    Last Post: 06-11-2012, 02:01 PM
  2. Replies: 12
    Last Post: 05-22-2011, 03:49 PM
  3. Convert Access query to SQL Server query
    By mkallover in forum Queries
    Replies: 2
    Last Post: 05-13-2011, 06:20 AM
  4. Convert Access 07 ADO code to SQL Server Express 2008
    By jrdnoland in forum Programming
    Replies: 8
    Last Post: 04-14-2010, 05:57 PM
  5. Convert query sql server for Access
    By webtony in forum Queries
    Replies: 0
    Last Post: 06-23-2009, 02:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums