i want to search in sql server with must have parameter in one colunm

Posted by sherif4csharp on Stack Overflow See other posts from Stack Overflow or by sherif4csharp
Published on 2010-05-10T15:49:48Z Indexed on 2010/05/10 15:54 UTC
Read the original article Hit count: 371

Filed under:
|
|

hello

i am usning c# and ms SQL server 2008 i have table like this

id | propertyTypeId | FinishingQualityId  |    title   | Description |  features  
1            1             2                 prop1          propDEsc1    1,3,5,7

2            2             3                 prop2           propDEsc2    1,3      

3            6             5                 prop3           propDEsc3    1

4            5             4                 prop4           propDEsc4    3,5

5            4             6                 prop5           propDEsc5    5,7

6            4             6                 prop6           propDEsc6    

and here is my stored code (search in the same table)

create stored procdures propertySearch

as

@Id int = null,
@pageSize float ,
@pageIndex int,
@totalpageCount int output,
@title nvarchar(150) =null ,
@propertyTypeid int = null ,
@finishingqualityid int = null ,
@features nvarchar(max) = null , -- this parameter send like 1,3 ( for example)


begin

select row_number () as TempId over( order by id) , id,title,description,propertyTypeId,propertyType.name,finishingQualityId,finishingQuality.Name,freatures

into #TempTable from property 

join propertyType on propertyType.id= property.propertyTypeId

join finishingQuality on finishingQuality.id = property.finishingQualityId

where 
property.id = isnull(@id,property.id ) and proprty.PropertyTypeId= isnull(@propertyTypeid,property.propertyTypeId)

select totalpageconunt = ((select count(*) from #TempTable )/@pageSize )

select * from #TempTable  where tempid between (@pageindex-1)*@pagesize +1 and (@pageindex*@pageSize)
end
go

i can't here filter the table by feature i sent. this table has to many rows i want to add to this stored code to filter data for example when i send 1,3 in features parameter i want to return row number one and two in the example table i write in this post (want to get the data from table must have the feature I send)

many thanks for every one helped me and will help

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql