Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Simple Member Search
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Simple Member Search

 Post Reply Post Reply
Author
gazeth View Drop Down
Newbie
Newbie


Joined: 14 August 2003
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote gazeth Quote  Post ReplyReply Direct Link To This Post Topic: Simple Member Search
    Posted: 14 August 2003 at 6:47am

I have created a simple stored procedure to which i send the following values

@strfirstname

@strsurname

@knownas

 

I want to search the members table for records matching any of the three using the LIKE statement however i don't want to have @strsurname LIKE '%%' how do i get around this in the stored procedure

 

Back to Top
Morgan View Drop Down
Groupie
Groupie


Joined: 13 September 2002
Location: United States
Status: Offline
Points: 114
Post Options Post Options   Thanks (0) Thanks(0)   Quote Morgan Quote  Post ReplyReply Direct Link To This Post Posted: 14 August 2003 at 7:38pm
So if "Smith" is passed in, you do not want "Smitherman" to be pulled up?
Morgan
Back to Top
gazeth View Drop Down
Newbie
Newbie


Joined: 14 August 2003
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote gazeth Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2003 at 2:32am

yes but if nothing is passed in then i don't want all records to be pulled up.

I need some checking in the stored procedure to see if the value is null or not. It's when the value is null i'm not sure what to replace it with.

Back to Top
Flamewave View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 June 2002
Location: United States
Status: Offline
Points: 376
Post Options Post Options   Thanks (0) Thanks(0)   Quote Flamewave Quote  Post ReplyReply Direct Link To This Post Posted: 25 August 2003 at 8:20am

at the beginig of the sp:

if @strsurname is null
    Goto END

at end of sp:

END:
Select 0 as NumRecords
Return 1

something along those lines

- Flamewave

They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.
Back to Top
Morgan View Drop Down
Groupie
Groupie


Joined: 13 September 2002
Location: United States
Status: Offline
Points: 114
Post Options Post Options   Thanks (0) Thanks(0)   Quote Morgan Quote  Post ReplyReply Direct Link To This Post Posted: 26 August 2003 at 5:27pm

CREATE PROC spTEST
   @strfirstname VARCHAR(30) = NULL,
   @strsurname VARCHAR(30) = NULL,
   @knownas VARCHAR(30) = NULL
AS
IF @strfirstname IS NULL
BEGIN
    RAISERROR('Must supply value for First Name', 16, 1)
    RETURN -1
END

IF @strsurname IS NULL
BEGIN
    RAISERROR('Must supply value for Surname', 16, 1)
    RETURN -1
END

IF @knownas IS NULL
BEGIN
    RAISERROR('Must supply value for Known AS', 16, 1)
    RETURN -1
END

...the rest of your stored proc here...
GO

Morgan
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.