Hi,
 I am sending a an argument to a store procedure, I will
 add a value to the "where" condition depending of that
 parameter.
 For example, the parameter is name, if i send "name1" I
 will add "AND name = 'name'" to the store produre
 (dynamic sql).
 Is there a way to do it without concatenating it to a
 nvarchar?
 like "where name = *" or sometign like this?
 Thanks a lot for your help!!
 JCWithout dynamic SQL:
WHERE @.name IS NULL OR name = @.name
--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.
"Juan Carlos" <jcarlos_mn@.hotmail.com> wrote in message
news:03eb01c34431$51a993a0$a301280a@.phx.gbl...
> Hi,
> I am sending a an argument to a store procedure, I will
> add a value to the "where" condition depending of that
> parameter.
> For example, the parameter is name, if i send "name1" I
> will add "AND name = 'name'" to the store produre
> (dynamic sql).
> Is there a way to do it without concatenating it to a
> nvarchar?
> like "where name = *" or sometign like this?
> Thanks a lot for your help!!
> JC|||For a detailed list of options refer to:
http://www.algonet.se/~sommar/dyn-search.html
--
- Anith
( Please reply to newsgroups only )|||Hi JC,
You may try something like this:
ISNULL( 'AND name = ''' + @.name + ''', '')
then, if @.name is null, the condition won't appear in WHERE clause... hope
this help
--
---
Charlie Yukio Nakagawa
---
"Juan Carlos" <jcarlos_mn@.hotmail.com> escreveu na mensagem
news:03eb01c34431$51a993a0$a301280a@.phx.gbl...
> Hi,
> I am sending a an argument to a store procedure, I will
> add a value to the "where" condition depending of that
> parameter.
> For example, the parameter is name, if i send "name1" I
> will add "AND name = 'name'" to the store produre
> (dynamic sql).
> Is there a way to do it without concatenating it to a
> nvarchar?
> like "where name = *" or sometign like this?
> Thanks a lot for your help!!
> JC
Monday, February 20, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment