Q&A archive

Stack Exchange Answers

Questions and answers Andy Mallon contributed across the Stack Exchange network.

DBA Stack Exchange

Why are there no "Daylight Time" time zones in SQL Server?

Question I am converting the times of some datetimeoffset columns from UTC to Eastern. I am doing this via the command UPDATE MyTable SET MyColumn = MyColumn AT TIME ZONE 'Eastern Standard Time' This seemed to be working correctly (times were shifted 4 hours …

Read answer

DBA Stack Exchange

SQL Server replication additional subscriber

Question I have a publisher with the distributor on the same server which is transactional replication. There is also an active subscriber using push method. I need to set a new subscriber up going to a different server using the same articles as the current …

Read answer

DBA Stack Exchange

Always backup database with encryption

Question Is there a way to force all database and log backups run on the server to be encrypted? If encryption is not specified, the query will be terminated. Asked2021-09-12byAvi Answer Not in SQL Server There is no option to force BACKUP DATABASE & BACKUP …

Read answer

DBA Stack Exchange

Partitioning and existing Indexes

Question I have a table that consumes almost 1.2 TB of space and has lots of historical data which are mostly irrelevant. Since performing bulk DELETE is going to cause a lot of heavy-lifting, I'm trying to use the concept of horizontal partitioning to create …

Read answer

DBA Stack Exchange

Identify how many CPUs our database server is using

Question Our server where the Microsoft SQL Server 2016 Web Edition server is installed is running very slow. We are thinking of increasing the number of cores licensed on it. However, we need to check how many CPU cores the database is using currently. Our …

Read answer

DBA Stack Exchange

Is it ok to change drive names/labels (NOT Drive Letters!)

Question I realize this is likely a simplistic question but my searches only return results for Drive Letters or Database names if I include SQL Server. Please feel free to point me to existing articles or answers, and my apologies in advance :)

Read answer

DBA Stack Exchange

insert on table being unnaturally slow

Question I have an "Basic" pricing tier Azure SQL database with a table of 7 columns, an ID column of int that is the clustered index and primary key, one datetime2(0) column, 3 varchar(100) columns and 2 varchar(MAX) columns, all nullable.

Read answer

DBA Stack Exchange

What are the .BCP files inside a .bacpak file?

Question Diving on dba.stackexchange.com I found a nice answer that teach me how to open a .bacpac file with File Explorer. I gave it a try with the database AdventureWorks2008R2 and all I did was: Save the database as .bacpac file Rename the file extension …

Read answer

DBA Stack Exchange

Job to stop other job at specific time

Question We have a job which imports data daily from a remote SQL Server every night, I'll call it Import-Job. Most of the time this job runs through in about 15 minutes and everything is fine but due to a rather unstable VPN connection sometimes the job …

Read answer

DBA Stack Exchange

Getting the first Monday after the third Friday

Question I have seen on this site how to get the the third Friday of the month: select quote_date FROM table where datename(weekday, quote_date) = 'Friday' and datepart(day, quote_date)>=15 and datepart(day, quote_date)<=21; How would I get the first Monday …

Read answer

DBA Stack Exchange

Identify all tables with an identity column

Question Is there a query I can run that will show me all tables with an identity column? Trying to figure out if there are any identity based tables whose current identity is nearing upper bound of int32 or int64.

Read answer

DBA Stack Exchange

Question Regarding ISDATE Function and DATENAME Functions

Question We have had an issue this morning with a report failing due to the following error: "Conversion failed when converting date and/or time from character string" The issue is that in the database we had a value (in a VARCHAR field) of: '31.07/2021'

Read answer

DBA Stack Exchange

SQL Server 2012 equivalent of AT TIME ZONE capability

Question Is there a way in SQL Server 2012 to get what the server time zone would be on a particular date/time? In SQL Server 2016, you have AT TIME ZONE, but that's not available in 2012. I have a datetimeoffset and I need to convert it to the server's …

Read answer

DBA Stack Exchange

OLE DB provider "MSOLEDBSQL" with SQL Server not supported?

Question I have been using linked server with the old provider (SQLNCLI) without any issue, as recommended by Microsoft, I'm planning to switch to new provider (MSOLEDBSQL). I'm able to add linked server using following T-SQL after installing the drivers EXEC …

Read answer