• Why not use T-SQL to generate the queries to be executed?  Then cut and paste the result of this into a text file to be executed using OSQL.

    For example,

    SELECT DISTINCT

    'SET NOCOUNT ON SELECT C. CustomerID, C. CompanyName, C.City, O. OrderDate, O. Freight FROM Customers C INNER JOIN Orders  O  ON C.CustomerID = O.CustomerID WHERE C.CustomerID = '''+C.CustomerId+''''

    FROM Customers C

         INNER JOIN

         Orders O ON C.CustomerID = O.CustomerID