Re: Parameters or no parameters - CASE statements
From: Alan (ambradnum_at_hotmail.com)
Date: 05/09/04
- Next message: graham: "What did I do wrong?"
- Previous message: Alric: "Re: Hostname Change and SQL"
- In reply to: Not Me: "Parameters or no parameters - CASE statements"
- Messages sorted by: [ date ] [ thread ]
Date: 9 May 2004 07:21:36 -0700
Hi Chris
If this query is to be used in a stored procedure then
this example should help:
--- create procedure spExample(@name varchar(50)) declare @myname varchar(51) if @name is null select @myname='%' else select @myname=@name select * from mytable where name=@myname go --- Hope this helps Alan "Not Me" <Not.Me@faker.fake.fa.kee> wrote in message news:<c7d9pk$ujl$1@ucsnew1.ncl.ac.uk>... > Hi, > > I would like to build a query that would take a number of parameters which > will be used for search clauses. What I would like tho is that if the > parameters are not given then no effect is had on the results. For example > if given the parameter @name I would like 'where name = @name' and if @name > was blank then i'd like either nothing, or just name = '%'. > > I've tried various ways of putting case statements in but keep getting > syntax errors.. where exactly are you allowed to use cases? > > Cheers, > Chris
- Next message: graham: "What did I do wrong?"
- Previous message: Alric: "Re: Hostname Change and SQL"
- In reply to: Not Me: "Parameters or no parameters - CASE statements"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
Loading