Solved

SQL Server Compare Parsed Strings

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to fix this error 14 48
Contained Database Collations 6 20
replication - alerts? 4 23
IN with @variable 5 20
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now