All the quotes are messed up. Remove them and type them back in. Did you get 
this off the internet somewhere?




From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of Brian McDonald
Sent: Friday, October 7, 2016 11:11 AM
To: mssms@lists.myitforum.com
Subject: [mssms] Re: Uptime and Last Reboot for Servers

[External Email]

I'm aware I was missing the 'S' in Select in the below. Here is the FULL query 
i'm running. [😊]


SELECT
cs.Name0 AS ‘ComputerName’,
DATEDIFF(HOUR, os.LastBootUpTime0, ws.LastHWScan)
AS ‘Uptime (in Hours)’,
CONVERT(VARCHAR(26), os.LastBootUpTime0, 100)
AS ‘Last Reboot Date/Time’,
CONVERT(VARCHAR(26), ws.LastHWScan, 101)
AS ‘Last Hardware Inventory’
FROM
dbo.v_GS_WORKSTATION_STATUS ws
LEFT OUTER JOIN dbo.v_GS_Operating_System os
ON ws.ResourceID = os.ResourceID
LEFT OUTER JOIN dbo.v_GS_COMPUTER_SYSTEM cs
ON cs.ResourceID = os.ResourceID
WHERE os.Caption0 LIKE ‘%server%’
ORDER BY os.LastBootUpTime0 ASC

________________________________
From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
<listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com>> on 
behalf of Brian McDonald 
<mcdonald...@hotmail.com<mailto:mcdonald...@hotmail.com>>
Sent: Friday, October 7, 2016 10:55:41 AM
To: mssms@lists.myitforum.com<mailto:mssms@lists.myitforum.com>
Subject: [mssms] Uptime and Last Reboot for Servers


Hello everyone,



I'm trying to determine the uptime and last reboot for servers. Below is the 
query I am trying to execute:


ELECT
cs.Name0 AS ‘ComputerName’,
DATEDIFF(HOUR, os.LastBootUpTime0, ws.LastHWScan)
AS ‘Uptime (in Hours)’,
CONVERT(VARCHAR(26), os.LastBootUpTime0, 100)
AS ‘Last Reboot Date/Time’,
CONVERT(VARCHAR(26), ws.LastHWScan, 101)
AS ‘Last Hardware Inventory’
FROM
dbo.v_GS_WORKSTATION_STATUS ws
LEFT OUTER JOIN dbo.v_GS_Operating_System os
ON ws.ResourceID = os.ResourceID
LEFT OUTER JOIN dbo.v_GS_COMPUTER_SYSTEM cs
ON cs.ResourceID = os.ResourceID
WHERE os.Caption0 LIKE ‘%server%’
ORDER BY os.LastBootUpTime0 ASC



I'm getting a syntax error,
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '‘'.



Can someone tell me what I'm doing wrong?



Thank you,



Brian




________________________________

Confidentiality Notice: This e-mail is from a law firm and may be protected by 
the attorney-client or work product privileges. If you have received this 
message in error, please notify the sender by replying to this e-mail and then 
delete it from your computer.

Reply via email to