Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Should I use a view?

Status
Not open for further replies.

csutton

Programmer
Joined
Dec 27, 2000
Messages
213
Location
US
Not sure if this should be done in a view, or stored procedure. Here is an example table:

Table A:
calldate
fielda1
fielda2
fielda3

Ok, I need to do a search to see "doe" is contained in either fielda1, fielda2, fielda3. "doe" could only be contained in 1 of the fields, not all 3. I could end up having 10 fields to check, or 2. I was wondering if the only way of doing this is in the WHERE clause such as "WHERE fielda1="doe" or fielda2="doe"" etc etc..

Any ideas?

Thanks,
Chris
 
I guess 'doe' is not hard-coded. What if you want to search for 'foo' or 'jane'?

This pretty much eliminates views.

Stored proc - better. Something like:

Code:
create proc usp_myProc( @value varchar(32) )
as

select <columnlist>
from myTable
where fielda1=@value OR fielda2 = @value etc etc...

go

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
Ok, that's kinda what i was thinking... but was hoping maybe I could just reference multiple fields by 1 name (so I could say call each field "name" and search for "doe" by doing WHERE name="doe" (or whatever the value is).

Oh well..

Thank you!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top