dbTalk Databases Forums  

Optional parameter on joined field which could be null?!

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Optional parameter on joined field which could be null?! in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ole S. Pedersen
 
Posts: n/a

Default Optional parameter on joined field which could be null?! - 08-04-2003 , 10:33 PM






I have two tables: eg. a person-table (no nulls allowed), with an id
and so on, and a person_course table (an intermediate table in a
many-to many relationship between person table and courses tables),
with two fields person_id and course_id.

But I want to make ONE multipurpose stored procedure, which has ONLY
optional parameters on all fields in the person table AND the field
course_id in the person_course table.

I have no problems making optional parameters on the person table (eg.
P.ID=ISNULL(@PersonID, P.ID ) ) BUT the problem is, when I try to add
an optional parameter on the field course_id it dosn't produce the
right results. Some times the course_id is null (because some persons
havn't joined a class yet).

Is there a way around it?

Ole S. Pedersen

Reply With Quote
  #2  
Old   
Simon Hayes
 
Posts: n/a

Default Re: Optional parameter on joined field which could be null?! - 08-05-2003 , 03:52 AM






osp (AT) stofanet (DOT) dk (Ole S. Pedersen) wrote in message news:<c09ea7ed.0308041933.45702538 (AT) posting (DOT) google.com>...
Quote:
I have two tables: eg. a person-table (no nulls allowed), with an id
and so on, and a person_course table (an intermediate table in a
many-to many relationship between person table and courses tables),
with two fields person_id and course_id.

But I want to make ONE multipurpose stored procedure, which has ONLY
optional parameters on all fields in the person table AND the field
course_id in the person_course table.

I have no problems making optional parameters on the person table (eg.
P.ID=ISNULL(@PersonID, P.ID ) ) BUT the problem is, when I try to add
an optional parameter on the field course_id it dosn't produce the
right results. Some times the course_id is null (because some persons
havn't joined a class yet).

Is there a way around it?

Ole S. Pedersen
http://www.algonet.se/~sommar/dyn-search.html

Simon


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.