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.
Author |
Topic |
Rg
Starting Member
10 Posts |
Posted - 2011-12-13 : 07:06:15
|
i am getting error how add this in dynamic querycan you please help me +'AND (isnull(@Lstatus,'''')='''') or A.Lstatus= @Lstatus)'+'AND ((isnull(@Dstatus,'''')='''') or A.Dstatus= @Dstatus)'rg |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-13 : 07:33:32
|
why you need extra braces? isnt below enough?..+'AND (isnull(@Lstatus,'''')='''' or A.Lstatus= @Lstatus)'+'AND (isnull(@Dstatus,'''')='''' or A.Dstatus= @Dstatus)' i've posted this based on query part posted so cant guarantee that above will work fine unless i see rest of part also------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
Rg
Starting Member
10 Posts |
Posted - 2011-12-13 : 08:00:10
|
above query is not working |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-12-13 : 08:01:00
|
Maybe this? 'AND (isnull('+@Lstatus+','''')='''' or A.Lstatus= @Lstatus)' +'AND (isnull('+@Dstatus+','''')='''' or A.Dstatus= @Dstatus)'JimEveryday I learn something that somebody else already knew |
|
|
Rg
Starting Member
10 Posts |
Posted - 2011-12-13 : 08:10:10
|
not working,i am getting error how add this in dynamic querycan you please help me+'AND (isnull(@Lstatus,'''')='''') or A.Lstatus= @Lstatus)'+'AND ((isnull(@Dstatus,'''')='''') or A.Dstatus= @Dstatus)' |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-12-13 : 08:46:23
|
Tell us what the error is that you are getting and please post your full query. Based on what you've told, mine or Visakhs could both be the right answer, or the wrong one.JimEveryday I learn something that somebody else already knew |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-13 : 08:47:02
|
what about this?'AND (isnull('+@Lstatus+','''')='''' or A.Lstatus= ' + @Lstatus + ')'+'AND (isnull('+@Dstatus+','''')='''' or A.Dstatus= ' + @Dstatus +')'------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|