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 |
|
savvy95
Starting Member
23 Posts |
Posted - 2005-04-04 : 09:48:27
|
| I've got 4 tables: users, computers, groups and ou with no join info. How can I create a view with info from all when there's no joining info?thanx for you help |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2005-04-04 : 10:01:23
|
| You can't.HTH-------Moo. :) |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-04-04 : 10:02:08
|
| cross joins ? unions ? some sample data and expected results and/or more specific information might be useful, don't you think? My crystal ball is in the shop this week ...- Jeff |
 |
|
|
andy8979
Starting Member
36 Posts |
Posted - 2005-04-04 : 10:11:37
|
Could you be specific in the output that you want from the view. what jsmith8858 has specified is perfect.........andy |
 |
|
|
savvy95
Starting Member
23 Posts |
Posted - 2005-04-04 : 10:14:29
|
| Thanks for you your humorous and quick replies. Maybe this will help:For the 4 tables, some column names are the same: DN, ObjectGuid, ObjectClass, userAccountControl and others, but others are not. For example computers have OperatingSystem which is not applicable to Users, Groups or OUs.My Expected Results -- I'm trying to create a view with all the information from the 4 tables, so I can query the view instead of each table individually.I've tried cross joins, but that gives me wrong info and since the table columns are different union doesn't work. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-04-04 : 10:23:37
|
| again, sample data or more specific info always helps. It sounds like you want a UNION. You can specify the columns as needed in your union, and use placeholders or default values for missing columns by specifying values in your SELECT statements. i.e.:Select ID, Name, Age, Null as BirthDatefrom Table1 -- note that BirthDate is missing from this tableunion allselect ID, Null as Name, Age, BirthDateFrom Table2 -- note that "Name" is mising from this tableDoes this help? - Jeff |
 |
|
|
savvy95
Starting Member
23 Posts |
Posted - 2005-04-04 : 11:13:57
|
| Thanx jsmith8858, that did the trick. |
 |
|
|
|
|
|
|
|