Solved

SQL Server Compare Parsed Strings

Posted on 2010-09-07
2
312 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 142

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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