Solved

SQL Server Compare Parsed Strings

Posted on 2010-09-07
2
318 Views
Last Modified: 2012-08-13
I'm trying to find all records in a table based on two parsed strings.  The first parsed string will be a series of IDs that need to be matched up to the IDs in the table.  The problem is that the IDs in the table are in one field that need to be parsed as well.  I've created a function fx_ParseString that will parse the string for me already. So far I have the following SQL Script:

SELECT *
FROM myTable
WHERE (SELECT * FROM fx_ParseString(IDs,'/')) IN
            (SELECT * FROM fx_ParseString(@IDs,'/'))

When I run this I get the following error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
0
Comment
Question by:chshelpdesk
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 33618352
please try this (change "value" by the column name returned by the fx_parseString function
SELECT t.* 
FROM myTable t
CROSS APPLY fx_ParseString( t.IDs,'/')) x
WHERE x.value IN (SELECT f.value FROM fx_ParseString(@IDs,'/') f )

Open in new window

0
 

Author Closing Comment

by:chshelpdesk
ID: 33618502
That's perfect.  Thanks!!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql query 8 51
SQL Server Insert where not exists 24 46
SQL Server Count where two id types exist in column 8 29
TSQL Challenge... 7 35
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question