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
 General SQL Server Forums
 New to SQL Server Administration
 Select what I need?

Author  Topic 

mqh7
Yak Posting Veteran

58 Posts

Posted - 2012-08-13 : 13:08:48
This first section of SQL code works. When run it will list all the PC Names. I assume it also lists the last logged on user but it does not display that.

SELECT DISTINCT v_GS_COMPUTER_SYSTEM.Name0 AS [PC NAME]
FROM v_GS_COMPUTER_SYSTEM INNER JOIN v_GS_system_console_user
ON (v_GS_SYSTEM_CONSOLE_USER.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID)
ORDER BY [PC NAME]


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



The view called v_GS_SYSTEM_CONSOLE_USER has the record called LastConsoleUse0 yet when I try to add this to my output I get an error. //Invalid object name 'v_GS_system_console_user.LastConsoleUse0'.//

How do I call this field and display it? Do I need 2 SELECT statements?

// this code does not work//
SELECT DISTINCT v_GS_COMPUTER_SYSTEM.Name0 AS [PC NAME]
FROM v_GS_COMPUTER_SYSTEM INNER JOIN v_GS_system_console_user.LastConsoleUse0 AS [LastUser]
ON (v_GS_SYSTEM_CONSOLE_USER.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID)
ORDER BY [PC NAME] .. ?? [LastUser] I would like displayed here

mqh7
Yak Posting Veteran

58 Posts

Posted - 2012-08-13 : 13:35:09
Got it

SELECT DISTINCT v_GS_COMPUTER_SYSTEM.Name0 AS [PC NAME], LastConsoleUse0 AS [Last Logged On User]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-13 : 14:11:37
time to learn some sql basics

http://www.w3schools.com/sql/default.asp

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mqh7
Yak Posting Veteran

58 Posts

Posted - 2012-08-13 : 14:44:09
Yes, I am. That is how I wrote the first section. Thanks for the link.
Go to Top of Page
   

- Advertisement -