Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 IN Clause Bugging the Crap Out of Me

Author  Topic 

derketo
Starting Member

28 Posts

Posted - 2005-01-10 : 22:14:55
Is there ANY way to use an IN clase inside a stored procedure without using dynamic SQL? The query I have to run is huge (the below is just a very small slice) and I need the performance boost. LIKE clause won't work...too many similarities between fields.

Thanks in advance.

CREATE PROC [dbo].[spTestABC]

@ParmUsername nvarchar(32)

AS

select Username
from Members
where Username IN (@ParmUsername)
GO

derketo
Starting Member

28 Posts

Posted - 2005-01-10 : 23:32:04
Forget it...using CSV.
Go to Top of Page

jbkayne
Posting Yak Master

100 Posts

Posted - 2005-01-10 : 23:32:31
Two ideas:

Use a User Defined Function to create a 1xN row table based on the input paramter which I assume is a comma delimited string.

Otherwise, pass in an XML document and create a table using OPENXML.


Good luck!
Go to Top of Page

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2005-01-11 : 00:14:25
Use this http://www.sqlteam.com/item.asp?ItemID=11499

You can pass in a csv string and you can get a table out of it. Its pretty cool
Go to Top of Page
   

- Advertisement -