title: SQL Results to JavaScript variable
body: <p>I am trying to select FirstNames from my SQL DB and then assign them to a JavaScript variable. (Each variable has to be unique)</p>
  
  <p>IE: Having the following database of names:</p>
  
  <pre><code>+---------+
  |FirstName|
  +---------+
  |Michael  |
  |Kevin    |
  |John     |
  |Michael  |
  |Steven   |
  |Michael  |
  |Tara     |
  |Nancy    |
  |Nancy    |
  |Steven   |
  +---------+
  </code></pre>
  
  <p>And the following query:</p>
  
  <pre><code>DECLARE @result varchar(250)
  SET @result = ''
  SELECT @result = @result + FirstName + ',' FROM Consultants GROUP BY FirstName
  select substring(@result, 0, len(@result)) as Name
  </code></pre>
  
  <p>I am able to get all the unique names into a string, something like this:</p>
  
  <pre><code>Michael, Kevin, John, Steven, Nancy, Tara
  </code></pre>
  
  <p>This is where I am now stuck... Is there a way to pull the names from the Results and assign them to a variable?</p>
  
  <p>IE:</p>
  
  <pre><code>var Consultant 1 = Michael
  
  var Consultant 2 = Kevin
  
  var Consultant 3 = John
  
  // And so forth....
  </code></pre>
  
  <p>I was thinking of building an array out of the names, but I also get stuck trying to do that.</p>
  
  <p>Sorry if this has been asked elsewhere, but I didn't manage to find it anywhere. Also - I hope I have explained this clearly enough.</p>
  
  <p><strong>EDIT</strong>
  I realized I left quite a chunk of info out. This is all happening on my asp page.</p>
  
  <p>So the SQL will be in my <code>&lt;%asp tags%&gt;</code> getting the info from the DB, then my JavaScript will follow after that.</p>