Q&A archive

Stack Exchange Answers

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

DBA Stack Exchange

Releasing free space in mdf file to OS

Question We have a 120GB database. There was table with 60GB of data which is useless and we have truncated it. Now database size is 120GB with free space 60GB. The database will not grow up to 60GB in at least 3 months. So can we shrink the data file.

Read answer

DBA Stack Exchange

SQL Triggers not preventing insert

Question I am having trouble getting a trigger to work. What it needs to do is to prevent any customer with last name Glass from being inserted into the database. This is what I have: CREATE TRIGGER no_last_name_glass_trg ON customer AFTER INSERT,UPDATE AS …

Read answer

DBA Stack Exchange

Converting date stored as a varchar

Question I'm creating a query that has a column of dates stored as a VARCHAR in the format DD-MMM-YYYY. Could you tell me how I can convert this into date format please? I don't want to alter the original table in any way, as it's not mine to tinker!

Read answer

DBA Stack Exchange

Transaction log is growing very fast

Question One of our SQL Server 2014 database transaction logs is growing very fast and I cannot find the root cause for this. Database in Simple recovery mode. During full backup the log file grows to its limits (800GB) and backup fails.

Read answer

DBA Stack Exchange

Risks of manual failover in Always On Availability Groups

Question In my environment, I have SQL 2014 with Always On Availability Group for databases in asynchronous with manual fail over. We have 1 primary and 2 secondary replicas--secondary1 and sec2. I have to do failover from primary to secondary1. I know some …

Read answer

DBA Stack Exchange

SQL Agent Job Logs - Can't get the Error Log

Question I've some logs that I want to extract to a report in order to get the SQL_Agent_Jobs status that runs during the night. If the Job fails then I want to receive the Error Log in a table. I am trying to get that information with this query:

Read answer

DBA Stack Exchange

Nonclustered index storage on clustered columnstore

Question In SQL Server, a non-unique nonclustered index on a rowstore table incorporates the base object’s bookmark (RID or clustering key) at all levels of the nonclustered index structure. The bookmark is stored as part of the nonclustered index key at all …

Read answer

DBA Stack Exchange

How often to update SQL Server?

Question I am a new DBA at a company that has never had a DBA before me. SQL Servers are never upgraded unless it is part of a Windows Update on the server. Service Packs (or CUs) are never installed. We have a mix of versions from 2000 to 2014.

Read answer

DBA Stack Exchange

Does the 'reads' column in SQL Profiler mean the same as IOPS?

Question I just executed a query that went pretty fast and the SQL Profiler said it used 30.000 reads. Now I'm looking at this page: https://cloud.google.com/compute/docs/disks/performance and see that a standard persistent disk has 3000 reads IOPS. Does that …

Read answer

DBA Stack Exchange

How to add 1100 columns in SQL Server

Question I need 1100 columns in a single table.I already have 928 columns in same table, now I need to add new 150 columns. I know SQL Server allow maximum 1024 columns. Now I will not create new table. If I create new table and join my require table, I need …

Read answer

DBA Stack Exchange

AlwaysON Migrate from 2014 to 2016

Question I have like 20 Listners on 2014 with approx 500 DBS, what is the best way to migrate these with least downtime, effort My idea is: Stop access Backup dbs Start restore dbs While restore is running: Drop AOG on 2014 Create it on 2016 Done

Read answer

DBA Stack Exchange

Is it possible to change the family_guid in MSSQL?

Question So I have a bit of a problem with some databases I'm trying to migrate to amazon RDS We have about 20 Databases that are all derivatives of others that all share the same family_guid because they are based on backups of others. The problem is that …

Read answer

DBA Stack Exchange

SQL Server 2014 slow insert

Question I have a very strange slow insert issue, here I am providing the table structure, and the insert statement used. The database is clean, contains no other tables, no indices, no constraints, no triggers. I tested this on two different machines, with …

Read answer