How To Use ADO and SQL Server to Select Multiple Records by Unique Field (294349)
The information in this article applies to:
- ActiveX Data Objects (ADO) 2.1
- ActiveX Data Objects (ADO) 2.1 SP1
- ActiveX Data Objects (ADO) 2.1 SP2
- ActiveX Data Objects (ADO) 2.5
- ActiveX Data Objects (ADO) 2.6
- ActiveX Data Objects (ADO) 2.7
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP3
- Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP4
- Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP5
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft SQL Server 7.0
- Microsoft SQL Server 2000 (all editions)
This article was previously published under Q294349 SUMMARY Sometimes the need arises to select one or more unique
values from a single field in an application. For example, this is useful when
you want to query a multiselect list box. The sample code in this article
demonstrates how to return a recordset based on values that match a list of
comma-delimited values that are sent to a SQL Server by using the IN
clause.
Note that this method is the fastest way to return records
based on multiple unique values. The SQL statement provides the minimum
information that is needed to return the results. The records that are returned
are only the records that are queried. You can further optimize the SQL
statement to return only the fields that are needed. REFERENCES For more information regarding the IN clause, see the
Microsoft SQL Server Books Online.
Modification Type: | Major | Last Reviewed: | 6/23/2005 |
---|
Keywords: | kbhowto KB294349 |
---|
|