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)
 Passing bit value to stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-10 : 12:16:36
Jeremy writes "I am trying to make a stored procedure where I pass it a bunch of criteria from a search form and it gives me all of the results as the output. It is for a school search page on the web.

The trouble I'm having is this: for certain bit values such as WebEnabled (checked when a school is to show up on the web and unchecked otherwise) I don't know how to receive and then dynamically query on that bit. I can receive blank strings for string search values because I do...

FieldName LIKE '%' + @PassedParameter + '%'

...so blank values find all basically.

But with bit values I've tried doing something like...


IF @PassedParameter = 1
WHERE FieldName = 1


I know that's not correct code, but I'm trying to give you an idea of what I want. I might never need to search based on a certain bit field being zero (i.e. Show me all schools that are not WebEnabled) so if necessary the 0 value could be used for "I don't care", but it would be nice if I could do Yes, No, or I don't care.

Somepeople have given me solutions that involve passing a dynamic SQL string into the stored procedure as a parameter, but that seems to violate the efficientcy advantages of an SP in the first place. There's got to be a better way.

Thanks in advance.

Jeremy Foster"
   

- Advertisement -