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

This is Why You Use Git for Scripts

Git has become a fantastic tool for me, and many other technologists, over the last ten years. It's almost ubiquitous in most of my clients, and so many people are comfortable with it. Many others aren't, which is why I started a Git series for DBAs (and other Ops people) on my blog.

Quite a few people asked me why I recommend git over a file share for storing code that a team of Ops people or DBAs might use. Why isn't a global file share a better choice in an organization? I think I have a few good reasons, but if you disagree, let me know in the discussion for this piece.

First, I've worked with a lot of file share tech over the years. Microsoft has done a good job of trying to ensure that a "file server" works well for organizations. I've used simple file shares on a particular server, I've had mapped drives to a file share appear on every desktop in the org, and I've even had to work with large orgs that use DFS (or something similar) to ensure we can replicate files across multiple servers for backup and speed.

All of those work, but they have a complexity, and a dependency on the team managing the file share. They also require a network connection to the share to see files, which isn't always as reliable and solid as we would like, especially in this modern world of working at home, databases in the cloud, and a widely dispersed workforce that uses BYOD devices. Don't get me wrong, those aren't bad things, but they complicate the idea of having a single global location for stuff.

Second, I want to version scripts because sometimes one team member alters a script for their piece of work, but it causes an issues with another member's use of the script. If we catch this quickly, we can usually CTRL+Z or revert the script, or we can copy it and then try to edit it into a new script for a different purpose. The challenge is we don't always catch it quickly. We also sometimes don't know what was in the old script. While I wish most of you logged the results of all executions, at the very least, save the script you ran. That's not easy to do in a file share.

Third, in the case above, the last writer wins. In a busy team, I've seen person A save changes to the script, then run it, while person B saves changes to the same script and runs it. Person A might get a "reload" notification and re-save theirs. Person b might do that, or they might reload Person A's changes and lose theirs. It's a nightmare. Imagine group Work or Google Docs editing of scripts while you try to execute them. That's a reason alone to use Git.

Lastly, with a file share, I'm dependent on some other group for backup and recovery. If they have an issue, I am hoping they didn't mess up my scripts. I have to wait on them if they are doing maintenance on the file share or patching the server.

With Git, I can keep the scripts on my machine, while easily replicating and sharing with others. We each have a backup of the script in case of emergency. We can even protect the main branch, forcing everyone to make changes on another branch and then use a pull request so that someone on our team can approve merging those changes into the main folder that we all use. If we don't like the script, or there are breaking changes, we haven't edited a file that others are using because it's in a branch.

Using Git (or any VCS) is a change in habit for many people, but it has a lot of benefits. I think it's worth the investment of time for teams.

Steve Jones - SSC Editor

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

 
 Featured Contents
SQLServerCentral Article

Attention SQLBits 2024 Attendees!

Press Release from SQLServerCentral

Microsoft will be featured at SQL Bits with a keynote speaker, a full day of training and a few other sessions. Register today for the conference in March and we hope to see you there.

Stairway to Biml

Stairway to Biml Level 6 - Programming with Metadata

Reeves Smith from SQLServerCentral.com

In this next level of the Stairway to Biml, learn how metadata makes your Biml code more efficient and helpful in generating packages.

External Article

Scientific Calculations in Power BI - Cube, Square, Logarithms, Powers, Inverse and more

Additional Articles from MSSQLTips.com

Microsoft Power BI Desktop provides users with multiple ways to help shape and transform their data. One of the options users have is scientific calculations, which support operations like cube, square, logarithms, etc. Power BI has this option in the Power Query Editor mode, where the user can easily apply one of these transformations for any number-based columns. In this tip, we will overview this utility in Power BI and how to benefit from it.

From the SQL Server Central Blogs - sp_snapshot – The easy way to take database snapshots of one of more databases – Version 2.0

david.fowler 42596 from SQL Undercover

Presenting you with an updated version of our sp_snapshot procedure, to easily create database snapshots. This new version adds more flexibility to the procedure, allowing you to specify the...

Blog Post

From the SQL Server Central Blogs - DBAs, Give Git a Try – Getting Started

Steve Jones - SSC Editor from The Voice of the DBA

One of the really interesting things over the last decade is both the rise of Git as the main VCS system for most projects, and the number of people...

SQL Server 2022 Administration Inside Out

Site Owners from SQLServerCentral

Dive into SQL Server 2022 administration and grow your Microsoft SQL Server data platform skillset. This well-organized reference packs in timesaving solutions, tips, and workarounds, all you need to plan, implement, deploy, provision, manage, and secure SQL Server 2022 in any environment: on-premises, cloud, or hybrid, including detailed, dedicated chapters on Azure SQL Database and Azure SQL Managed Instance.

 

 Question of the Day

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

 

The Default Variable String

What is returned by the second SELECT in this code in SQL Server 2022?
DECLARE @s VARCHAR;
SELECT @s = 'this is a test of a fairly long string'
SELECT @s

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)

An Updatable View

I have this view, based on a table where CityNameID is an identity field.

CREATE VIEW dbo.City 
AS
SELECT 
 cn.CityNameID, cn.CityName
 FROM dbo.CityName AS cn
GO

I want to make it updatable to run this code:

INSERT City (CityName) VALUES ('Elbert')

What do I need to do?

 

Answer: Nothing. This view is updatable.

Explanation: All views are updatable, if they meet a few restrictions on what the SELECT statement includes. In this case, the view is updatable. Ref: CREATE VIEW - https://learn.microsoft.com/en-us/sql/t-sql/statements/create-view-transact-sql?view=sql-server-ver16#updatable-views

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 2017 - Administration
SQL Server Always On Availability Group in an Active/Passive Cluster Environment - I currently have a setup where we have an Active/Passive Cluster Environment that also has a Disaster Recovery Secondary Availability Group. There is a need for another secondary replica to use the read-only functionality to reduce the workload on the Primary Replica. My main question here is I'm assuming I will have to have another […]
Bad checksum in Image column - We have a large table that stores file data in a column with an Image data type.  One of the records appears to have corrupt data.  When trying to select the record with the file data, I get the following error: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, […]
SQL Server 2016 - Administration
Migrate MS SQL Cluster to a New SAN - Hi, As the titles states, I am in the process of moving my sql cluster from an older SAN to a new one. I reviewed and partially followed this post: How-To: Migrate MS SQL Cluster to a New SAN but I can not do this: Back in Failover Cluster Manger right click on the old […]
SQL Server 2019 - Administration
Create a dynamic script to create view for all tables having MAX columns - Hi I need some help on this request Create a dynamic script to create view for all tables having MAX columns in the database And if the column is MAX then I need to use CONVERT(VARCHAR(2000), SUBSTRING (COLUMN_NAME,1,2000)) as COLUMN_NAME in the view Thanks      
RESERVED_MEMORY_ALLOCATION_EXT wait and totally slowness - Hi, we have a little bit of an interesting topic. Sometimes, we get wait RESERVED_MEMORY_ALLOCATION_EXT, we have 12TB RAM , and not all are full but the primary server is totally slow, whoisactive is not possible run, other queries are waiting for this memory wait or also DTC or HADR SYNC, and we tried to […]
ALTER SERVER AUDIT -- need to supply 1 predicate with 2 values to filter on - Looking for example FILTER containing multiple values in the predicate -- to apply to "ALTER SERVER AUDIT" Need to filter on 2 SERVER_PRINCIPAL_NAMES which I do not want captured in my DATABASE AUDIT (EG. thousands of rows of activity for Idera's SQLdm ID:  'mydomain\!sqlmonitoring' and our standard service account performing the DML 'myDomain\myServiceAccount') An internet […]
Minimal permission to stop a SSIS execution from Active Operations dashboard? - What is the minimal permission to allow a user (who is not a member of the SYSADMIN or SSIS_ADMIN role) to stop a SSIS operation using the [stop] command button on the Active Operations dashboard? This would be similar to the SQLAgentOperatorRole for SQLAgent - except for SSIS operations.
SQL Server 2019 - Development
Function Returning NULL on Specific Server Instance, 0 on Other Servers - This has me very perplexed... we have a function that on one server is returning a 0 but on another server it returns a NULL: USE TempDB GO CREATE FUNCTION dbo.TestNuLL() RETURNS BIT AS BEGIN DECLARE @MyBit BIT; SET @MyBit = 0 SELECT @MyBit = 1 WHERE 1 = 0 RETURN @MyBit END I tested […]
Reporting Services
Error in conditional summing - I'm creating a SSRS report pulling from SSAS cube using a MDX Query. In my report I'm trying to sum conditionally inside a grid using the following expression. =Sum(iif((Fields!TOC_DIsplay.Value = "Default TOC" or Fields!TOC_DIsplay.Value = "Labor" or Fields!TOC_DIsplay.Value = "Non-Labor"), cdec(Fields!Next_Year_Budget__E_.Value), cdec(0))) I'm getting the following error when the column has no values. Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: The […]
Powershell
Throw error without stack trace - Hi all   We're using PowerShell V5 on a SQL2022 Enterprise box.   I've got  SQL Agent job step that calls a PS script.   Occasionally, the step fails but doesn't fail the job (it just carries on regardless).   I need this step to fail the job so I've been looking at the PS […]
Integration Services
Connecting Oracle Database with SSIS - Hi, I have Visual Studio 22 and I am trying to connect to Oracle database among other sources. I can not see Oracle as an alternative when creating OleDB data sources. I installed 32 bit 'Oracle Client for Microsoft Tools' which my client provided for me ==> no luck I googled this and that and […]
SQLServerCentral.com Website Issues
504 Gateway Time-out – The server didn't respond in time. - I've been getting this error more and more frequently. It happens when I respond to a post … especially if mine is the first response, it seems. Despite the error, the post is usually made successfully.
SQL Server 2022 - Administration
User-Friendly Task Executor / Scheduler - We have a requirement to allow certain nominated users to execute 'jobs', where the definition of a job could be running a stored proc, or a PoSh script, or some other command line task. I'd be interested to know how others here provide this functionality to their users. Any recommendations for a suitable tool? This […]
SQL Server 2022 - Development
Conditionally Selecting Rows within Union - Hello, I have a union where I need to select rows from the first query if the Car Status column is equal to "New". Otherwise, I need to select rows from the second query in the union which comes from a separate db and table if the Car Status column in the first query equals […]
Declare XMLNAMESPACES - Hello fellows, does anyone know how to format XMLNAMESPACE declaration so that its output is formatted specific way? ; WITH XMLNAMESPACES ( DEFAULT 'fsrv', 'http://www.w3.org/2001/XMLSchema-instance' as xsi, 'fsrv PositionRec.xsd' as schemalocation, '30' as Version ) SELECT GETDATE() for XML PATH ('TestPath'), ROOT ('AcctFncl') /******************************************************************************************************* The output of the below script gives me namespaces declaration on […]
 

 

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

 

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