Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
The Voice of the DBA
 

A Great Case for Powershell

This editorial was originally published on May 21, 2018. It is being re-run today as Steve is on vacation. Let us know how well it holds up.

I think PowerShell is a great addition to the Microsoft stack. Given the previous versions of VBScript, Perl and Python ports, and more on Windows, PowerShell is a great improvement. Even for someone that spent a lot of time in the C Shell and Bourne Shell as a student and young professional, I think PowerShell is an improvement. There are certainly still things that make me crazy about PoSh, such as the -eq, but I'm getting more comfortable with the structures and flow.

In SQL Server, we had the old SQLPS module, which was, well, a start. Then we got the SqlServer module, which is better. However, the best thing I've seen for us data professionals is the dbatools project from Chrissy LaMaire (@cl) and company. To me, this is incredibly useful for anyone that wants to use PoSh with SQL Server, but it's really indespensible for SQL Server migrations from instance to instance. I'm not sure I'd even try anything else at this point.

Not everyone wants to use PoSh with SQL Server, and that's fine. There are certainly plenty of places where T-SQL works very well to manage and interact with SQL Server. I still prefer it for many things, but the more I work outside a database, whether for administrative actions or manipulating parts of the platform away from SSMS, PowerShell has some advantages. Not the least of which are cleaner file operations and certainly better string manipulation (IMHO).

Recently I saw post from Drew Furgiuele about finding linked servers in your object code with PoSh. It's a long, somewhat convoluted post, and some of you might wonder if it's worth the effort. Hint, it's not worth the effort because Drew has done it for you. He's got the function on Github, and if you need to move linked servers, just use his code to help.

My point is, however, that doing this in T-SQL would be a nightmare. Just going through search isn't helpful, though SQL Search is a great tool. The work to find the objects would be hard, and this isn't something you want to get wrong in a migration. It would be bad enough to have errors for non-existent linked servers, but it might be worse if you had code pointing to the wrong database. This is something you'd want to fix, and PoSh helps work with a complex problem here.

There are other issues like this, other problems or requirements that look across instances or more intensely at parts of our systems outside of what we want to do with T-SQL. Certainly anything at scale, that might be something you do for many instances is better with PoSh, and certainly any infrastructure as code items that work to stand-up and configure SQL Server really should use PoSh.

Don't make PowerShell a hammer, and try to solve all issues, but for the future, you really ought to be sure you are comfortable reading PoSh scripts and know how to use them with SQL Server. Learn when PoSh is a good alternative, and certainly know where you can get scripts or help with your code.

Steve Jones - SSC Editor

Join the debate, and respond to today's editorial on the forums

 
 Featured Contents
SQLServerCentral Article

The Problem Isn't Always Your Query or Schema... Sometimes It's Hidden Assumptions

dbruton95 from SQLServerCentral

Sometimes the problems aren't your code. Here a few places where re-examining your assumptions can help improve software development.

External Article

How to determine the last value used by a sequence in SQL Server

Additional Articles from SimpleTalk

I’ve been a fan of sequences ever since they were added in SQL Server 2012. Prior to that, developers had a choice of IDENTITY columns or a roll-your-own table mechanism.

Blog Post

From the SQL Server Central Blogs - The Burrito Bot: AI-Powered Search in SQL Server 2025

dbafromthecold@gmail.com from The DBA Who Came In From The Cold

A while back I posted about a couple of side projects that I’ve been working on when I get the chance. One of those was the Burrito Bot…a bot...

Blog Post

From the SQL Server Central Blogs - Monday Monitor Tips: Intelligent Alert Thresholds

Steve Jones - SSC Editor from The Voice of the DBA

At the recent Redgate Summit in Chicago, I demo’d (lightly) the ML based Alert thresholds in Redgate Monitor and decided to write a little about this. This is part...

Definitive Guide to DAX cover

The Definitive Guide to DAX: Business Intelligence for Microsoft Power BI, SQL Server Analysis Services, and Excel

Site Owners from SQLServerCentral

Now expanded and updated with modern best practices, this is the most complete guide to Microsoft’s DAX language for business intelligence, data modeling, and analytics. Expert Microsoft BI consultants Marco Russo and Alberto Ferrari help you master everything from table functions through advanced code and model optimization.

 

 Question of the Day

Today's question (by Steve Jones - SSC Editor):

 

Identity Defaults

What happens when I run this code?
CREATE TABLE dbo.IdentityTest
(
     id int IDENTITY(10) PRIMARY KEY,
     somevalue VARCHAR(20)
)
GO

Think you know the answer? Click here, and find out if you are right.

 

 

 Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Identities and Sequences III

When thinking of the Identity property for auto incrementing columns and sequences for the same action, which can be used with the BIGINT data type?

Answer: Both

Explanation: Both support BIGINT A Sequence default to BIGINT if the type isn't specified. Identity can be set on a BIGINT column Ref:

Discuss this question and answer on the forums

 

 

 

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.


SQL Server 2019 - Development
String_agg not working as needed - I'm trying to get this string_agg to put all the 'comments' into one result field like instead of: 433    2018-11-06 11:08:12.793     Customer called 433     2018-11-06 11:08:12.793     Customer left message This is needed: 433    2018-11-06 11:08:12.793     Customer called, Customer left message Any ideas?: WITH MaxCommentCTE AS ( SELECT DISTINCT client_id […]
query to track time spent on individual tasks in SSIS - Hi everyone I am looking at building a query to determine how much time is being spent on each task in SSIS.  My SSIS package has a few containers and within each container there are tasks.  Once one container finishes processing then the next container gets processed.  I have never done this before so I […]
Editorials
Is Your Time "Free"? - Comments posted to this topic are about the item Is Your Time "Free"?
Doing the Little Things - Comments posted to this topic are about the item Doing the Little Things
Everything is the right question away - Comments posted to this topic are about the item Everything is the right question away
Hidden Heroes - Comments posted to this topic are about the item Hidden Heroes
Article Discussions by Author
Identities and Sequences II - Comments posted to this topic are about the item Identities and Sequences II
Using PostgreSQL as a NoSQL Store and a Search Engine - Comments posted to this topic are about the item Using PostgreSQL as a NoSQL Store and a Search Engine
Seeding a Fabric Warehouse with dbt for Visual Studio Code: The Fabric Modern Data Platform - Comments posted to this topic are about the item Seeding a Fabric Warehouse with dbt for Visual Studio Code: The Fabric Modern Data Platform
Seeding a Fabric Warehouse with dbt for Visual Studio Code: The Fabric Modern Data Platform - Comments posted to this topic are about the item Seeding a Fabric Warehouse with dbt for Visual Studio Code: The Fabric Modern Data Platform
Historical Data Tracking - Comments posted to this topic are about the item Historical Data Tracking
Vectors in SQL Server 2025 - Comments posted to this topic are about the item Vectors in SQL Server 2025
Odd Sequences - Comments posted to this topic are about the item Odd Sequences
SQL Server Transactional Replication from Always On Availability Groups to Azure SQL Database - Comments posted to this topic are about the item SQL Server Transactional Replication from Always On Availability Groups to Azure SQL Database
Identities and Sequences I - Comments posted to this topic are about the item Identities and Sequences I
 

 

RSS FeedTwitter

This email has been sent to {email}. To be removed from this list, please click here. If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com. This newsletter was sent to you because you signed up at SQLServerCentral.com.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

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