SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to use multiple select statements
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

hh1234
Starting Member

30 Posts

Posted - 03/14/2012 :  15:53:30  Show Profile  Reply with Quote
I have this code which works fine.

select distinct
Name0, ResourceID, User_Domain0, User_Name0, AD_Site_Name0,

from v_R_System

where v_R_System.ResourceID NOT IN (Select v_R_System.ResourceID
from v_R_System inner join v_GS_ADD_REMOVE_PROGRAMS on v_GS_Add_Remove_Programs.ResourceID = v_r_System.ResourceID
where
v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 = '%Quest Secure Password Extension x64%')


I need to add this to the code:

SELECT LastConsoleUse0
From v_GS_SYSTEM_CONSOLE_USER


And then I need the LastConsoleUse0 to appear as a Column in the final output.


How do you do that?

tkizer
Almighty SQL Goddess

USA
35017 Posts

Posted - 03/14/2012 :  15:57:56  Show Profile  Visit tkizer's Homepage  Reply with Quote
How does that new bit relate to the data, meaning how would you associate each row from v_GS_SYSTEM_CONSOLE_USER to the data in your current query?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

hh1234
Starting Member

30 Posts

Posted - 03/14/2012 :  16:06:20  Show Profile  Reply with Quote
NAME0 is the NetBIOS name of the PC. So I want LastConsoleUse0 (the last time a user logged on) associated with NAME0. That why we can tell for each machine the last time someone logged into the PC.

I hope that is what you were asking.
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35017 Posts

Posted - 03/14/2012 :  16:35:21  Show Profile  Visit tkizer's Homepage  Reply with Quote
Are NAME0 and LastConsoleUse0 the same? I can't tell from your explanation. Or is NAME0 available in this other view?

It'll probably help us if you showed us a data example.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

Edited by - tkizer on 03/14/2012 16:35:51
Go to Top of Page

hh1234
Starting Member

30 Posts

Posted - 03/14/2012 :  16:47:40  Show Profile  Reply with Quote
Name0 is from from v_R_System
LastConsoleUse0 is from v_GS_SYSTEM_CONSOLE_USER

so they are from totally different views.


Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35017 Posts

Posted - 03/14/2012 :  16:49:06  Show Profile  Visit tkizer's Homepage  Reply with Quote
You are missing my point. In order to add this additional view, it has to relate to the data in your current query. What is the relation? How are we supposed to add the view without knowing the relation?

How about you show us the columns being returned from v_GS_SYSTEM_CONSOLE_USER?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

hh1234
Starting Member

30 Posts

Posted - 03/14/2012 :  17:00:07  Show Profile  Reply with Quote
I want to join these two statements

SELECT
v_GS_COMPUTER_SYSTEM.Name0,
v_GS_COMPUTER_SYSTEM.UserName0,
v_R_System.User_Name0
FROM
v_GS_COMPUTER_SYSTEM v_GS_COMPUTER_SYSTEM,
v_R_System v_R_System
WHERE
v_R_System.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID
ORDER BY
v_GS_COMPUTER_SYSTEM.Name0


---------------------------------------------------------------------

select distinct
Name0, ResourceID, User_Domain0, User_Name0, AD_Site_Name0,

from v_R_System

where v_R_System.ResourceID NOT IN (Select v_R_System.ResourceID
from v_R_System inner join v_GS_ADD_REMOVE_PROGRAMS on v_GS_Add_Remove_Programs.ResourceID = v_r_System.ResourceID
where
v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 = '%Quest Secure Password Extension x64%')


So I can find out all machines that do Not have the Quest software installed. I get the PC name and the last user who logged into the PC.

Thanks.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000