We want to check for a pending restart. If a server is awaiting a reboot before attempting to to install new software or make OS changes. These powershell examples will help with checking the last reboot date and time as well as return a Yes and No if it is… Read more »
This is an advance process that allows us to prepare a cluster node or likely multiple nodes quickly. We will use the configuration file feature and install the SQL services and instance level resources on each node so they are exactly the same. Then we fail all of the drives… Read more »
In this example we will be connecting to a MySQL database using the Visual Studio Code IDE. We will also setup a Python environment and install the MySQL Connector needed to connect to MySQL and MariaDB. The instructions should be similar on Windows, Mac and Linux but will not be… Read more »
Following up on the last post about dates and using Get-Date we look at the difference between dates and how to compare or calculate them. Dates can be tricky because you are counting on the system to do the calculation correctly but this requires passing the right info or string…. Read more »
No matter what Database you deal with there will be times where you need to manipulate or calculate dates and Powershell offers many different methods to get them. Whether you’re going back in time to 90 days ago or you need to set a variable for a future time and… Read more »
Searching for and cataloging the SQL server instances on your network is a key part of Administration. Powershell offers some quick and simple methods to find servers base on the their name or description in Active Directory. We can use the Powershell module to collect these servers and add them… Read more »
Working with data in a DataTable means understanding how to find, sort and select what you need. Since this blog is about database we are basically looking at selecting data similar to the T-SQL command. The Select distinct statement returns only 1 for each unique record. This includes combinations so… Read more »
The DataTable is an extremely useful Object when working with different sources and types of data in SQL and using Powershell. The DataTable Class is packed with Methods to work with data coming, going relationships and more. Creating a DataTable is a simple as: In this example we are focusing… Read more »
For the Python experienced Developers & DBA’s I thought I would include an article about connecting to SQL server similar to the SQL server powershell version we wrote recently. I tested this code using PyCharm and a new virtual environment that did not have pyodbc. To connect to SQL Server… Read more »
The articles I found on Relational Database design are pretty dry and academic. The assumption is you are a seasoned Database Developer and you fully understand all of the terminology and why things like data types and columns are even needed. They tell you to list all of your data… Read more »
The SSMS application is very versatile and can be easily used to export queries you run into a simple comma separated file (CSV). This is great when your working with only one instance but what if you need to consolidate data from multiple instances in the environment? With this example… Read more »
For most DBA’s we will use SSMS and connect to the SQL instance to see if a databases exists and is spelled correctly. This is usually in response to troubleshooting a connection so connecting to the SQL instance makes sense as you may need to check the login permissions too…. Read more »
Learning to create and manage stored procedures in SQL is another useful SQL databases skill for the DBA and developer. The Procedures allow you to create repeatable code that can be executed using just a database single call. We can also design the procedure to handle passing parameters into it…. Read more »
Collecting version information for your environment is a never ending task but Powershell can be used to make things easier. Each SQL server instance can be different and a single server can have multiple SQL instances with different versions. In SQL server we can use SSMS to run the following… Read more »
This is a Powershell script I’ve used for a few years that creates a dated folder and places a backup for a single database in it. This version uses the “Invoke-Sqlcmd” and you may need to install the module before using this script. Install-Module sqlserverGet-Command -ModuleName sqlserver You only need… Read more »