January 3, 2007 at 4:25 am
ok this is doing my head in!
create procedure myproc
@aValue bigint
begin
as
select aField from tableA
inner join tableB on tableA.aField = tableB.aField
where tableB.aField = @aValue
end
this works fine..but what i want to be able to do is to not filter on the 'aValue' if it is set to 0. ( so effectively the query becomes..
select aField from tableA
inner join tableB on tableA.aField = tableB.aField
)
i know i can do this with dynamic sql but i would rather find another way if it is possible, unfortunately my tsql is letting me down.
any help appreciated!
January 3, 2007 at 4:41 am
Have you tried:
create procedure myproc
@aValue bigint
begin
as
select aField from tableA
inner join tableB on tableA.aField = tableB.aField
where tableB.aField = @aValue
OR @aValue = 0
end
Give this a go, let me know how it goes! Good luck.
January 3, 2007 at 4:54 am
Ahh yes. thats pointed me in the right direction..cheers.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply