Solved

comma delimited string in where clause

Posted on 2012-04-02
2
1,339 Views
Last Modified: 2012-06-27
Hello All,

Trying to write a stored procedure that will works as follows,

propertyid is a asp.net arraylist converted to comma delimited string ex: dc,me,dp
buildingis is a asp.net arraylist converted to comma delimited string  ex: tmc,omm,ccd

The table column default value for both is "All"

@propertycode As nvarchar(256),
@buildingcode As nvarchar(256)

I tried the slpit function from here but had no success.
http://www.codeproject.com/Articles/30681/Split-parameter-string-from-comma-seperator-in-SQL

SELECT propertyName, propetyId from tblproperties Where
(propertycode IN (select * from UF_CSVToTable(@propertycode)) And buildingCode IN (select * from UF_CSVToTable(@buildingcode))Or propertyCode = 'All') or
(propertycode IN (select * from UF_CSVToTable(@propertycode)) and buildingCode ='All' )

Thanks for reviewing my question.
0
Comment
Question by:GrantBailey
2 Comments
 
LVL 9

Accepted Solution

by:
mimran18 earned 500 total points
ID: 37799372
0
 

Author Closing Comment

by:GrantBailey
ID: 37801336
Fantastic! Thank you.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

757 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

18 Experts available now in Live!

Get 1:1 Help Now