title: Performing query on two databases with stored procedure for returning two sets of data on dropdown
body: <p>I have two drop downs on a form. Second drop down populates based on value selected on the first drop down. One of two stored procedures query I have basically displays data where the value for @LocID does not match selected on first dropdown does not exist and also performs subquery where no zipcodes are returned for anything matched with the declared @LocID.</p>
  
  <pre><code>DECLARE @LocID INT;
  
  SELECT
   DISTINCT l.[ZipCode],
   [Description] = l.ZipCode + ' - ' + l.Description
  FROM LocMap l
    WHERE l.ZipCode NOT IN (
    SELECT l2.ZipCode
    FROM LocMap l2
    WHERE l2.LocID = @LocID
  );
  </code></pre>
  
  <p>Table named LocMap.</p>
  
  <pre><code>LocID | ZipCode | Description
  ----------------------------------
  100  | 91012   | Magical Sky
  100  | 91013   | Dream Land
  101  | 91012   | Blue Ocean
  102  | 91012   | Gray Screen
  104  | 91014   | Limit Break
  108  | 91016   | Magic Hammer
  </code></pre>
  
  <p>My problem is my second stored procedure that also returns data to this second dropdown labeled as Recently Added. It basically queries a table and returns all data for it (ZipCode + Description), no criteria or anything. What I would like to know is if it is possible to query two databases on the same server and if so, how exactly I would perform the same filtering of data I am doing on my stored procedure above with the stored procedure query for this second table. The first stored procedure has the @declare LocID, but this second one, all it does is return everything without anything being declared. </p>
  
  <p>1) What would be the recommended way of doing this. Is it possible to get the results from first stored procedure and do a subquery similar to filter out my data with RecentlyAdded? Just like the first query, I don't want to return any zipcodes that match the LocID passed on this second table result as well.</p>
  
  <p>Second stored procedure table named RecentlyAdded</p>
  
  <pre><code>ZipCode | Description
  ----------------------------------
  91018   | Zelda
  91019   | Sephiroth
  91012   | Cloud
  91012   | Aeris
  91011   | Tifa
  91010   | Barrett
  
  Dropdown Layout Example
  
  [Select LocID] (First Dropdown)
     100
     104
     108
     120
  
  [Select ZipCode - Description] (Second Dropdown]
    ---Recently Added---
      91010 - Barrett
      91018 - Zelda
      ......................
      ......................
      ......................
    ---All other ZipCodes---
      91016 - Magic Hammer
      91014 - Limit Break
      ......................
      ......................
      ......................
  </code></pre>