Finally the help of IT is here

Blog of computer solutions.

How to make a SQL query from a command line in WSUS.

Written by Xaus Xavier Nadal on February 28th, 2010

Good.

Following the above 3 items ...

As for me it is not enough to make a SQL query from the WSUS server for missing patches for teams going to do to send me an email with the list of patches installed equipment.

To do this I need to do the query from the command line to automatically generate me a file and send it to me by email.

SQLWSUS_13

First of all we need the utility Microsoft SQL Server Native Client y Microsoft SQL Server Command Line Query Utility 2005.

Dischargeable from:

http://www.microsoft.com/downloads/details.aspx?FamilyID=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&DisplayLang=en

SQLWSUS_12

SQLWSUS_11 

When you may have installed only we go to a command line: Start -> Run -> cmd.exe and press OK to validate.

Now we write sqlcmd -S \\. \ Pipe \ MSSQL $ MICROSOFT ## substations \ sql \ query -E

and we are already connected to the server command line.

If we execute a query because we only use modifiers correctly:

sqlcmd-S \\. \ Pipe \ MSSQL $ MICROSOFT ## substations \ sql \ query -E -d "SUSDB" -Q "SELECT dbo.tbComputerTarget.FullDomainName, dbo.tbComputerSummaryForMicrosoftUpdates.NotInstalled, dbo.tbComputerSummaryForMicrosoftUpdates.Downloaded, dbo.tbComputerSummaryForMicrosoftUpdates.Installed, dbo.tbComputerSummaryForMicrosoftUpdates.Failed, dbo.tbComputerSummaryForMicrosoftUpdates.InstalledPendingReboot FROM dbo.tbComputerSummaryForMicrosoftUpdates ON INNER JOIN dbo.tbComputerTarget dbo.tbComputerSummaryForMicrosoftUpdates.TargetID = dbo.tbComputerTarget.TargetID "

-S For the server name.

-d for the name of the database.

-Q For the SQL query and exit.

Well if we now use a pipe to redirect it to a file as > listadopcs.txt at the end of the previous command.

sqlcmd-S \\. \ Pipe \ MSSQL $ MICROSOFT ## substations \ sql \ query -E -d "SUSDB" -Q "SELECT dbo.tbComputerTarget.FullDomainName, dbo.tbComputerSummaryForMicrosoftUpdates.NotInstalled, dbo.tbComputerSummaryForMicrosoftUpdates.Downloaded, dbo.tbComputerSummaryForMicrosoftUpdates.Installed, dbo.tbComputerSummaryForMicrosoftUpdates.Failed, dbo.tbComputerSummaryForMicrosoftUpdates.InstalledPendingReboot FROM dbo.tbComputerSummaryForMicrosoftUpdates ON INNER JOIN dbo.tbComputerTarget dbo.tbComputerSummaryForMicrosoftUpdates.TargetID = dbo.tbComputerTarget.TargetID "> listadopcs.txt

we have a file with the result of the SQL query. And if we send it by mail because you know how to use the fantastic Blat.exe. You can see where to download it and as used in the following article: Script to send mail with AD teams <ServicePack desired

I hope you liked it. Megacracks soon.

Related Posts Plugin for WordPress, Blogger ...
Tags: , , , , , , , ,


Leave a Reply

XHTML: You can use in Original tags: <a href="" title=""> <abbr title = ""> <acronym title = ""> <b> <blockquote cite = ""> <cite> <code> <del datetime = ""> <em> <i> <q cite = ""> <s> <strike> <strong>

GTranslate Your license is inactive or expired, please subscribe again!