title: sp_msforeachdb in dataset
body: <p>Can someone tell me why the following code only returns one row from the DataSet (for the master db) instead of one for each database on the server?  </p>
  
  <pre><code> $SQLConn = New-Object System.data.SqlClient.SqlConnection
   $SQLConn.ConnectionString = "Data Source = $SQLServer; Initial Catalog = master;
                               Integrated Security = True"
   $SQLConn.Open()
  
   $query = "exec sp_msForEachDb 'use [?] SELECT TOP 1 [name] FROM sysusers'"
  
   $SQLCmd = New-Object System.Data.Sqlclient.SqlCommand($query, $SQLConn);
   $SQLAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
   $SQLAdapter.SelectCommand = $SQLCmd
   $DataSet = New-Object System.Data.Dataset
   $SQLAdapter.Fill($DataSet) | out-null
  
   ForEach ($row in $DataSet.Tables[0])
   {
      $Name = $row["name"]
      write-host $Name
   }
  
   $SQLConn.Close()
  </code></pre>