You are here: Stored procedure with unknown numer of paramters, how? « MsSQL Server « IT news, forums, messages
Stored procedure with unknown numer of paramters, how?

Posted by Igor on 03/29/06 13:27

I have one table with categories

tblCategories

cat_id | cat_name

-----------------

1 | cat 1

2 | cat 2

3 | cat 3

4 | cat 4

5 | cat 5

6 | cat 6





and one table with projects which relates to tblCategories

tblProjects

proj_id | proj_name | cat_id

----------------------------

1 | proj 1 | 2

2 | proj 2 | 2

3 | proj 3 | 3

4 | proj 4 | 2





How would you create stored procedure for searching some string in
filed proj_name but within multiple categories



for example

CREATE PROCEDURE [spSearch]

(

@SEARCH_STRING nvarchar(200),

@CAT_ID int

)

AS

BEGIN

SELECT proj_id

FROM tblProjects

WHERE (proj_name LIKE '%' + @SEARCH_STRING + '%') AND (cat_id =
@CAT_ID)

END



But that one works only with one categorie and i need to search for one
or more categories at once, does anyone have a solution? Is there
something like ellipsis (...) in C++ for MSSQL?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация