Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 7th, 2006, 08:15 PM
SoC SoC is offline
Authorized User
Join Date: Jul 2004
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default vbscript version of SQL 'SELECT DISTINCT'


I am querying our Active Directory to built a phone list. I wanted to select a distinct list of locations, but it looks like MS's ADSI SQL dialect does not support 'SELECT DISTINCT'.

So I'm guessing I'll have to build a distinct list on the client side with vbscript, but my vb knowledge is very limited. Can someone point me in the right direction?

Do I need to create an array or something? Or does vbscript have another way of manipulating the recordset to pull out only distinct values form a particular field?


Old February 8th, 2006, 03:16 AM
SoC SoC is offline
Authorized User
Join Date: Jul 2004
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts


Managed to use a dictionary object - stored the unique records in it. Problem is I'm sure it's a lot slower than a SQL Select Distinct equivalent, cos my solution is happening on the client side:

set objD = CreateObject("Scripting.Dictionary")

while not myRS.EOF
    myString = myRS.Fields("physicalDeliveryOfficeName")
    if not objD.Exists (myString) then
        objD.Add myString, myString
    end if
Then to display the unique results in a select box:

<select name="sel1">
myResults = objD.Items
for i = 0 to objD.Count - 1%>
set objD = nothing

Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Distinct kirkmc Access 13 July 13th, 2006 01:26 PM
Select Distinct kirkmc Excel VBA 3 May 5th, 2006 07:55 PM
Select Distinct? hugh@kmcnetwork.com SQL Language 5 November 5th, 2005 09:58 AM
Distinct SELECT DISTINCT question... EndEffect Classic ASP Databases 4 August 18th, 2005 08:53 AM
select distinct bmains ADO.NET 0 April 8th, 2004 02:50 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.