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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Search Query

Author  Topic 

rammohan
Posting Yak Master

212 Posts

Posted - 2008-10-25 : 02:42:46
i Had six master tables say tb1,tb2,tb3,tb4,tb5,tb6
tb1:
id1 int primary key,
name1 vrahcr(250) not null
tb2:
id2int primary key,
name2 vrahcr(250) not null
tb3:
id3 int primary key,
name3 vrahcr(250) not null
tb4:
id4 int primary key,
name4 vrahcr(250) not null
tb5:
id5 int primary key,
name5 vrahcr(250) not null
tb6:
id6 int primary key,
name6 vrahcr(250) not null

the relation table tb7 is:

id7 int primary key
id1 int references id1
id2 int references id2
id3 int references id3
id4 int references id3
id5 int references id5
id6 int references id6

here i am performing a search query with sp.
@p1 int,@p2 int,@p3 int,@p4 int,@p5 int @p6 int are parameters for sp

here i need to write a query to satisfy all the condition by checking the parameters if they r null or not:
all the combinations need to satisfied:
p1,p2,p3,p4,p5,p6,p1&p2,p1&p3,p1&p4 etc.. all combinations.

i need to get the name fields in that respective tables id the parameter is not null
please suggest me a way






One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-25 : 02:54:10
so what will you be returing if parameters match coresponding id values? the corresponding names? can you elaborate on that giving sample output for some values passed?
Go to Top of Page

rammohan
Posting Yak Master

212 Posts

Posted - 2008-10-25 : 03:02:58
thank you for replying visakh,
yes i want to return names.
sampleo/p:

name1
x if @p1 contains a matching value n all other r null

name1 name3
x y if @p1&@p3 contains a matching values n all others r null

etc...

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

Go to Top of Page
   

- Advertisement -