Results 1 to 2 of 2
  1. #1
    Mansi is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    3

    Move Select statement from MS Access to SQL Server

    Hi,


    I have select statement below written in MS Access, I want to use it in sql server side, How Can I move it to be run there?


    SELECT [History Other Charges].Institution, Sum(IIf([other_item]='ID' Or [other_item]='CID',[other_extended],0)) AS Internal, Sum(IIf([other_item]='DRCTS',[Other_Extended],0)) AS Dr_Coats, Sum(IIf([other_item]='ML',[other_extended],0)) AS Misc_Linen, Sum(IIf([other_Item]='Mops',[other_extended],0)) AS Mops, Sum(IIf([other_item]='PR',[other_extended],0)) AS Plastic, Sum(IIf([other_item]='Rags',[other_extended],0)) AS Rags, Sum(IIf([other_item]='SPCHG',[other_extended],0)) AS Special, Sum(IIf([other_item]='ABS',[other_extended],0)) AS ABS, Sum(IIf([other_item]='GCC',[other_extended],0)) AS GCC
    FROM [History Other Charges]
    WHERE ((([History Other Charges].Other_Date) Between #3/1/2010# And #3/31/2010#))
    GROUP BY [History Other Charges].Institution;

    thanks in advance,
    MM

  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,521
    Sure; IIf() does not exist in T-SQL, but you can use CASE instead. Check out the syntax in BOL. Also, in T-SQL you'll want to surround the dates with single quotes instead of #.
    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. Use of COLLATE statement in SELECT clause
    By zurek in forum Queries
    Replies: 7
    Last Post: 03-16-2011, 06:46 AM
  2. What is wrong with my SQL Select statement?
    By John2810 in forum Programming
    Replies: 2
    Last Post: 04-01-2010, 10:30 AM
  3. Replies: 3
    Last Post: 02-01-2010, 08:26 AM
  4. Convert query sql server for Access
    By webtony in forum Queries
    Replies: 0
    Last Post: 06-23-2009, 02:46 AM
  5. Access / SQl Server Advantage.
    By caljohn527 in forum Queries
    Replies: 0
    Last Post: 01-24-2009, 06:40 PM

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