SQL Equivalent of VB JOIN()

Results 1 to 2 of 2

Thread: SQL Equivalent of VB JOIN()

  1. #1
    Join Date
    Dec 1969

    Default SQL Equivalent of VB JOIN()

    does SQL have a way of converting multiple single-column records into one delimted record like a VB JOIN()?<BR><BR>turn:<BR>A<BR>B<BR>C<BR><BR>into:<B R>A,B,C<BR><BR>yes, i know how to do it with ASP, and i also could write my own function, but i was wondering if there was one already written?<BR><BR>thanks

  2. #2
    Join Date
    Dec 1969

    Default Short answer: no

    Longer answer: It wouldn&#039;t make sense.<BR><BR>The whole point of SQL is to return records. You are asking it to convert a *set* of records into a single record.<BR><BR>Why? To what profit?<BR><BR>You could probably do this with a stored procedure (in, for example, SQL Server), but you&#039;d actually probably do *more* work than doing it in VBS code.<BR><BR>Now, you *could* almost do this with a combo of SQL and ADO:<BR><BR>&#060;%<BR>Set RS = conn.Execute( "SELECT myOneField FROM table WHERE whatever" )<BR>myString = RS.GetString( , , "", "," )<BR>%&#062;<BR><BR>The only thing wrong with that is that you&#039;ll have a trailing comma after the last item in the string. You could ignore it or chop it off, thus:<BR><BR>&#060;%<BR>myString = Left( myString, Len(myString)-1 )<BR>%&#062;<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts