title: Converting a query from Oracle PL/SQL to Microsoft T-SQL
body: <p><strong>UPDATE: Thanks for all your help guys! I just need to take a litte bit of time to tlook through the results and I will definitely mark the answer. Really appreciate everyone's feedback!</strong></p>
  
  <p>I have the following query that needs to be converted from Oracel PL/SQL to T-SQL to accomodate a data source change. I've already done the work needed to isolate the logic (still written in PL/SQL) and merely need to adjust the remaining parts. Things like TO_DATE have, in particular, been tricky to convert so I decided to turn to StackOverflow.</p>
  
  <p>I have already heard about the SwisSQL tool but as this is just an isolated instance of a single query that needs conversion using that product in not a possibility. Any and all help in converting the query to use proper T-SQL synthax would be greatly appreciated. Thank you for your time and here's the query in question:</p>
  
  <pre><code> SELECT
              F.TYPE_ID,
              TRIM(f.event_type_name),
              TRIM(e.event_name),
              NVL(trim(e.event_title),' '),
              e.cur_event_state,
              TO_CHAR(D.EV_START_DT, 'YYYYMMDD') ,
              TO_CHAR(D.EV_START_DT,'HH24MI') ,
              TO_CHAR(D.EV_END_DT, 'YYYYMMDD') ,
              TO_CHAR(D.EV_END_DT,'HH24MI') ,
              TO_char(d.EV_START_DT, 'D')
      from rooms C,
           SP_RESERVATIONS D,
           EVENTS E,
           event_types f
      where @Room = TRIM(replace(C.room_short(+),'-','*'))
  AND C.ROOM_ID = D.ROOM_ID
        AND D.EVENT_ID = E.EVENT_ID
        and e.event_type_id = f.type_id
        and f.type_id in ('22','40','70','71','72','105','121','119')
        AND (D.EV_START_DT
                       BETWEEN TO_DATE(:WS-TERM-START-DATE,'YYYYMMDD')
                          AND TO_DATE(:WS-TERM-END-DATE,'YYYYMMDD')
         OR  D.EV_END_DT
                       BETWEEN TO_DATE(:WS-TERM-START-DATE,'YYYYMMDD')
                          AND TO_DATE(:WS-TERM-END-DATE,'YYYYMMDD'))
        and not e.cur_event_state = '59'
  </code></pre>
  
  <p>Thanks!</p>