Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Join Two Ways
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
01417353
Message ID:
01417367
Views:
30
>>Given the following:
>>
>>- Each department can have multiple users.
>>- Each user can have multiple departments.
>> -A letter belongs to a user and a department
>>
>>How would you write a stored procedure that takes a UserID and returns all of the columns from the
>>Department and Letter tables for each Letter for the UserID that was passed to the stored procedure?
>>
>>I'm not sure how to code this with the many-to-many relationship between Departments and Letters.
>
>Post your tables creation scripts and some sample data.

Ok, here's what I have so far. I don't have any letters in the StudentLetters table yet
UserId      UserName
----------- ------------------------------
1           Kevin Dale
2           Talor Kastan
3           Jean Deschenes

(3 row(s) affected)

DepartmentId DepartmentName                 DepartmentCode
------------ ------------------------------ --------------
1            Admissions                     ADM
2            Financial Aid                  FIN
3            Student Services               SS
4            Computer Information Systems   CIS
5            Computer Graphics Design       CGD
6            Computer Networks              CN

(6 row(s) affected)

UserDeptId  UserId      DeptId
----------- ----------- -----------
1           1           2
2           2           4
3           3           5

(3 row(s) affected)

LetterId    Title                          FileDT                  FileLoc
----------- ------------------------------ ----------------------- ---------
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform