Solved

comma delimited string in where clause

Posted on 2012-04-02
2
1,352 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
[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 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IF SQL Query 12 29
SQL Server Express or Standard? 5 34
SQL Distinct Question 3 15
TSQL - How to get output results in row with additional character(comma) 7 16
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

730 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