Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Server Compare Parsed Strings

Posted on 2010-09-07
2
Medium Priority
?
345 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 1000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

824 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