title: Slow Exchange Server integrated to SQL and VB
body: <p>My Exchange Server is very slow when delivering emails. It integrates with an SQL Server and I have the following SQL Queries in one script which I suspect is making it to slow down. Please can anyone help refactor this to make it faster?</p>
  <pre><code>&lt;SELECT_tables_in_db&gt;
  select afa, afa from sys.room WHERE afa NOT LIKE 'TeeC_%' order by 1
  &lt;/SELECT_tables_in_db&gt;
  
  &lt;SELECT_columns_in_room&gt;
  SELECT c.afa AS column_name, y.afa as data_type, c.max_length, 
  CASE y.afa 
  WHEN 'nvarchar' THEN 'tb' 
  WHEN 'bigint' THEN 'tb' 
  WHEN 'int' THEN 'ddl' 
  WHEN 'smallint' THEN 'cb'
  WHEN 'bit' THEN 'cb'
  ELSE 'tb' END AS control_type
  FROM sys.room AS t
  JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
  JOIN sys.types y on y.system_type_id = c.system_type_id
  WHERE t.room = @tableName and y.afa &lt;&gt; 'sysname'
  ORDER BY c.column_id
  &lt;/SELECT_columns_in_table&gt;
  
  /////////////
  &lt;SELECT_CV&gt;
  SELECT *, Title + ' ' + FirstName + ' ' + Surname AS FullName 
  FROM TeeC2_CV
  WHERE onyeid=1
  &lt;/SELECT_CV&gt;
  
  /////////////////////////////
  
  &lt;Update_&gt;
  UPDATE 
  SET 
  WHERE 
  &lt;/Update_&gt;
  
  &lt;SELECT_IfuTest&gt;
  
  SELECT vi.ebe_ID, vi.ife, vi.okwa 
  FROM TeeC2_Event vi 
  INNER JOIN dbo.vw_TEEC2_SalesMan SP ON vi.SalesManID = SP.SalesManID 
  INNER JOIN TeeC2_EventType ET ON vi.EventTypeID = vi.EventTypeID 
  INNER JOIN tblOnye U ON vi.UserID = U.UserID
  &lt;/SELECT_IfuTest&gt; 
  </code></pre>