Solved

SQL Server Compare Parsed Strings

Posted on 2010-09-07
2
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Negative isnull? 3 32
Using this function 4 54
Database Mail Profiles 1 51
MSSQL Convert Char to Date Time 5 36
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
In this article I will describe the Copy Database Wizard 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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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