troubleshooting Question

SQL Union syntax in VBScript?

Avatar of usslindstrom
usslindstromFlag for Japan asked on
VB ScriptMicrosoft SQL ServerDatabases
2 Comments1 Solution1037 ViewsLast Modified:
Experts, I have the 3 following individual queries that I run from VB against SQL.

I'm trying to figure out how to make them a "UNION SELECT" statement, but can't get the syntax right.

Would somebody know how I could update the 3 individual query strings into a single one? - that way I can do a DISTINCT against the query to drop duplicates.

Thanks for any information you can provide.
objRecordSet.Open "SELECT PrinterName, DriverFileName, DriverTextString, ModelNumber FROM " & SQLTable_PrinterMap_Global, _
            objConnection, adOpenStatic, adLockOptimistic


    objRecordSet.Open "SELECT PrinterName, DriverFileName, DriverTextString, ModelNumber FROM " & SQLTable_PrinterMap_Room & " WHERE RoomNumber = '" & ComputerLocation & "'", _
            objConnection, adOpenStatic, adLockOptimistic


    objRecordSet.Open "SELECT PrinterName, DriverFileName, DriverTextString, ModelNumber FROM " & SQLTable_PrinterMap_Computer & " WHERE ComputerName = '" & ComputerName & "'", _
            objConnection, adOpenStatic, adLockOptimistic

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros