Scripts

Technical Article

PowerShell script to create SQL Server alias name

This script is useful for your environment having multiple always-on with replication setup and your listener value is persisted with RegisterallIP set to 1. When initiating the always-on failover, It will create/update the alias in the distributor server by pointing to the new primary server without RDP to each distributor server and that makes the […]

4.33 (3)

You rated this post out of 5. Change rating

2021-07-07 (first published: )

1,518 reads

Technical Article

How to shrink tempdb database in SQL Server

This article discusses different methods that you can use to shrink the tempdb database in Microsoft SQL Server. Before you shrink the tempdb database using the methods described in this article, note the following: The tempdb size is reset to the final configured size (i.e. to the default size or the final size that was […]

1 (2)

You rated this post out of 5. Change rating

2021-06-09

3,499 reads

Technical Article

Space allocated to the databases by disk letters

Found this useful for database migrations. This helps to identify how much space will need to be allocated for a new server and how a SQL Sever instance is using discs currently. Note. This won't show correct information on Linux instances and if you use mounting points in Windows.

3 (2)

You rated this post out of 5. Change rating

2021-04-23 (first published: )

923 reads

Technical Article

Execute on DMVs without user having View Server State

Wanted to share this script to the community just in case anyone out there may be search for a way to allow a hosted customer the ability to query certain DMVs for information without granting them View Server State. There are some other options out there, but this worked better for me after going through […]

5 (1)

You rated this post out of 5. Change rating

2020-09-24

2,015 reads

Technical Article

Fiscal/Retail 4-5-4 Calendar Function

This function returns a 3 year calendar based on a 4-5-4/5-4-4/4-4-5 calendar, also known as a 52/53 week calendar.  The basis of this calendar function was derived from the NRF retail calendar published at https://nrf.com/resources/4-5-4-calendar and the Wikipedia article published at https://en.wikipedia.org/wiki/4%E2%80%934%E2%80%935_calendar. The calendar function requires 2 helper functions.  The helper functions were derived from […]

You rated this post out of 5. Change rating

2020-09-21 (first published: )

2,716 reads

Technical Article

Table Variable Deferred Compilation (SQL 2019)

I have explored the SQL Server 2019, Intelligent Query Processing Feature – “Table Variable Deferred Compilation”.

The script contains some theory at the top and links to read.
After that, there are required queries to run on SQL Server 2019.
This way we can see the feature in action and look at it's strengths and caveats.

3.67 (3)

You rated this post out of 5. Change rating

2020-08-03

1,507 reads

Blogs

Simple Talks Episode 9–Data masking and subsetting

By

The episode on data masking and subetting is out. You can see it here:...

T-SQL Tuesday #180: Avoid Perfect for Good Enough

By

I'm listening to Effortless by Greg McKeon (link to author's page) through Audible.com. He...

Book Review – Humanizing Data Strategy by Tiankai Feng

By

This book was making its rounds on social media, and the concept seems interesting...

Read the latest Blogs

Forums

Does SSRS Report with Stored Procedure execute SQL string?

By danyeungw

I declare @Where based on the input parameter in the stored procedure. Set @SQL...

SQL Server Constrained Delegation

By cw255

Hi, hoping someone can help. We're in the process of migrating to a new...

Get Sum and Last month sum

By GrassHopper

I want to get the sum and I want to get the sum of...

Visit the forum

Question of the Day

Comparing Images

I am building an ETL process between these tables in SQL Server 2022 set to 160 compatibility level:

CREATE TABLE Image_Staging
( imageid     INT NOT NULL CONSTRAINT Image_StagingPK PRIMARY KEY
, imagestatus TINYINT
, imagebinary IMAGE);
GO

CREATE TABLE Images
( imageid       INT NOT NULL CONSTRAINT ImagesPK PRIMARY KEY
, imagestatus   TINYINT
, imagemodified DATETIME
, imagebinary   IMAGE);
GO
I want to run this query to check if the images already loaded exist. This will help me decide if I need to insert or update an image. What happens with this query?
SELECT i.imageid
FROM
  dbo.Image_Staging AS ist
  INNER JOIN dbo.Images AS i
    ON ist.imagebinary = i.imagebinary;

See possible answers