Sql Installation For Sp3d Free

By: Alejandro Cobar | Updated: 2019-09-25 | Comments (1) | Related: More >Database Administration

Free download sql express trace Files at Software Informer. Express Agent from Vale Software is a SQL Express job scheduler lets you create and schedule jobs to backup SQL Server databases and run.


Problem

You are starting as a new DBA and there are hundreds of SQL Server instances thathave been installed by someone no longerwith the company. Wouldn't it benice to be able to know, for these hundreds of instances, when each was installed?That can give you a rough idea of how long the SQL Server services (now under yourcare) have been around.

Solution

In this tip I'm going to present you a PowerShell script that you can useto fetch the installation date for all the SQL Server instances that you specify,within a single run.

Code explained, along with some assumptions

To be able to use this, you need to have compiled (or at least have been handed)a list of servers under your care. You are free to choose the way to feed the PowerShellscript with the list of instances to traverse (e.g. a separate text file with suchlist), but in this tip (and as I always do within all of my tips) I'm goingto use a table that I have populated with such information.

Here is a brief overview of each section of the PowerShell script below.

##SECTION 1

  • The script can work with the parameter $populateInstances (which by defaultis set to 0).
    • When 0, it means that you already populated the instances table andwon't be doing so within the script.
    • When 1, it means that the script will populate the instances table foryou, which requires you to enter them in ##SECTION 3.
  • The $server and $inventoryDB values should be modified to specify your SQLServer instance and database where you will be centralizing the informationcollected.

##SECTION 2

  • In this section, 3 tables will be created for you, in case they don'talready exist.
    • The first one is where the instances list will be stored, and a tablewith the name of instances.
    • The second one is where the results fetched from each instance willbe stored.
    • The third one is an error log table to capture any error encounteredwhile trying to fetch the results from each individual instance.

##SECTION 3

  • In this section, the $populateInstances parameter is evaluated and if youenter 1 then it will attempt to insert the respective instance inthe instances table.
    • Please make sure to replace the XXXX with the values to fit your usecase (feel free to add more parenthesis if you need).

##SECTION 4

  • In this section, the list of instances to traverse is specified and executed.After the list has been retrieved from the central SQL Server instance, it willbe stored within the $instances variable.

##SECTION 5

  • This section contains the TSQL code that will retrieve the installationdate from all the instances.

##SECTION 6

  • Prior to attempting to do anything, the table 'instances_installation_date'is TRUNCATED so that results obtained within each script execution are not accumulatedover time. If you wish to accumulate results over time, for whatever reason,feel free to comment or delete this section.
  • This section contains the main mechanics that perform the work, using thefollowing high-level approach:
    • For each instance found in the instances table, apply the TSQL from##SECTION 5.
    • Within a try/catch block, the connection to the instance is made andthe information is fetched from it.
    • If there's an error while trying to connect to the instance, orif there's an error with the query itself being passed, then sucherror will be logged in the table called 'error_log' so thatyou can perform the respective troubleshooting later. If an error is encountered,then that particular instance will be skipped, and the script will continuewith the rest without interrupting its execution.
    • Finally, the respective INSERT statement that is dynamically built duringthe loop is applied and the information can be viewed in the target tableat the end.
PowerShell Script to Find SQL Server Installation Date for All Instances

In my case I have 3 instances, so initially my instances table will look likebelow. I have entered an instance called 'Localhost2', which doesn'texist, that will be used to show what happens when the script can't makea connection to a valid instance.

Since I already have the instances table populated, the script will be executedwith the $populateInstances parameter set to 0, and this is what you will see inthe console:

As you can see, all the results were successfully fetched from each validinstance and the error was correctly reported for the 'invalid'one. If you take a look at the error log table, it will look like this:

  • The first column gives you a hint to know which script logged the error,in case multiple different scripts are running in your environment and use theexact same table.
  • The second column tells you the name of the instance with the issue, atleast it tells you the name of the instance supplied to the script that throwsthe error.
  • The message column contains the actual error message thrown by SQL Server,for troubleshooting purposes.
  • The error_timestamp column helps you keep track of when the error was reported.

Here's the results table after being populated by the script:

Next Steps
  • You can go a bit further and automate this execution through aSQLServer Agent Job.This will make sure that when a new instance is deployed, then it will haveits installation date updated in your inventory.
    • The addition of the new instance would have to be manual, but it is totallyworth the effort.
  • You might think: 'Hey, I can do the exact same thing against a set ofRegistered Servers inSQL Server Management Studio' … and yes, you are totally right! The purpose of this isto give you one more way to accomplish the task.
  • Download the PowerShell script and test it in your development / testenvironment prior to moving to production.

Sql Installation For Sp3d Free Trial


Last Updated: 2019-09-25

For

Sql Installation For Sp3d Free Download



About the author

Sql Installation For Sp3d Free Downloads

Alejandro Cobar is an MCP, SQL Server DBA and Developer with 10+ years of experience working in a variety of environments.
View all my tips

Sql Installation For Sp3d Free Online