title: SQL query stored procedure
body: <p>Create a stored procedure that passes in the <code>SalesOrderID</code> as a parameter.
  This stored procedure will return the <code>SalesOrderID</code>, Date of the transaction, shipping date, city and state. It is not running</p>
  
  <p>Ans:</p>
  
  <pre><code>Create PROCEDURE proc_findProductInfo
      @SalesOrderID int,
      @SalesOrderOut int OUTPUT,
      @OrderDate datetime OUTPUT,
      @ShipDate datetime OUTPUT,
      @CityState varchar(100) OUTPUT
  AS
  BEGIN
      SET NOCOUNT ON; 
      SET @SalesOrderOut = @SalesOrderID
      SET @OrderDate = (SELECT OrderDate FROM SALES.SalesOrderHeader )
      SET @ShipDate = (SELECT ShipDate FROM Sales.SalesOrderHeader)
      SET @CityState = (SELECT a.City, st.Name
                        FROM Sales.SalesOrderHeader s  
                        INNER JOIN Person.Address a ON                s.ShipToAddressID = a.AddressID
                        INNER JOIN Person.StateProvince st ON s.TerritoryID = st.TerritoryID
                        WHERE SalesOrderID = @SalesOrderID)
  END
  
  DECLARE @OrderNum int, @Date datetime, @qty1 int, @Date1 datetime
  
  EXEC proc_findProductInfo 63936, 
                       @SalesOrderOut = @OrderNum OUTPUT,
                       @OrderDate = @Date OUTPUT,
                       @ShipDate = @date1,
                       @CityState = @qty1 output
  
  SELECT @OrderNum, @date, @qty1, @Date1
  </code></pre>
  
  <p>Error Message:</p>
  
  <blockquote>
    <p>Msg 116, Level 16, State 1, Procedure proc_findProductInfo, Line 25<br>
    Only one expression can be specified in the select list when the
    subquery is not introduced with EXISTS</p>
  </blockquote>