SQL Server Query Failing - sql-server

I have 2 servers Server A and Server B. They both have SQL Server 2016 SP2-CU7 installed with 64 GB memory and same amount of disk space for Temp DB. I allocated same amount of memory for both servers (48 GB).
When I run a script it fails on Server A with this error:
Could not allocate space for object 'dbo.SORT temporary run storage: 140737993048064' in database 'tempdb' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.
But on Server B it runs in 3 minutes without any issues. I requested more space for TempDb drive on Server A but the script still fails.
How can I find out what is wrong with Server A?

Related

SQL Server 2008 R2 - database file is 10GB, can't shrink it

I've got a database on SQL Server 2008 R2 that has grown to 10GB (log file is tiny). Users cannot work because they get the message about not being able to allocate space, filegroup PRIMARY being full.
Database is in simple mode, the .mdf file is set to unlimited growth, the initial size says 10240MB and when I change it trough the manager it just goes back up.
Naturally shrinking trough Manager or T-SQL DBCC SHRINKFILE or SHRINKDATABASE does not work because of that (IIRC, shrink cannot go below minimal size).
What are my options now?
Create a new filegroup?
Why can't I reduce initial size?
SEE IMAGE

Is restoring a database on existing one (replacing) different from restoring database by deleting the existing one in MS SQL Server?

I have to restore a database of 1 TB size from Production to Development. The current Development database is of 500 GB size and I have 700 GB free space on Development server SQL drive. Now, I should be able to restore the DB to Dev as 500+700=1200 GB space available on DEV. Is this possible or should I drop the existing 500 GB Dev database and restore the Prod backup on DEV?
How come, replacing the existing database by restore, is different from dropping the existing db then restore in MS SQL Server context?
Can anybody please explain?
If you restore into an existing db name, then SQL Server will delete the existing database for you and then create the new (database files) so that the restore process can copy data from the backup to the (newly created) database files. I.e., same thing as if you first delete the database.
(If the existing database file has the same logical name and file size, then the actual file deletion and creation doesn't happen since the "containers" are already there.)

DBCC CheckDB require how much size of the Tempdb

An automatic job running to do the DBCC CheckDB for all of our database on SQL Server 2008 R2.
we have 22 DBs, and 1 of the db has about 160GB, I relocate a hard drive around 70 GB for the tempdb but it failed.
CheckDB Error : 1105 : Could not allocate space for object 'dbo.SORT temporary run storage: 172324227579904' in database 'tempdb' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup. [SQLSTATE 01000]
I would like to know how much size I need for this db check.
After using the Estimateonly check, it only gives me an answer 45MB....which is a bug in MS SQL SEVER 2008 R2, so I try to connect to the database via SQL Serever 2012 and lanch the Estimateonly but the same answer.
Any guy could help me about how to get the exact size I need for a big DB DBCC check?
Sincerely
For more information.
#TheGameiswar. I did a check on our SQL Server Pack. we already have the latest version of the SQL Server...
enter image description here

TRN file is very big

We had a maintenance plan on our SQL server 2000 database with log shipping from main server to standby server. We had to disable the plan due to disk space issues. After resolving that we did a log backup and enabled the plan, but now the initial trn file being created is huge and we had to stop the job in the middle as it was going towards low disk space again. We didn't do any index rebuild, what could be the cause of trn file getting so big?
We also have an archive server (SQL server 2012), which runs an SSIS module, which copies certain data across and deletes it from main server, could that be related to this? The archive did bloat the main transaction log file (.ldf) but after running the aforementioned log backup the percentage of log space used was reduced and the LDF is not growing anymore for now. The LDF file itself is pretty big.

Discrepency in the size of mdf files in SQL server

I am having 2 .bak files for the same database in MSSQL Server. One is the test snapshot and the other is the production snapshot. The test one is about 500 MB and the production one is about 10 GB. This is because the Test one has many tables truncated. When I restore them in sql server a .mdf file is created at \Microsoft SQL Server\MSSQL.1\MSSQL\Data folder. But I see that the sze of the .mdf file is about 10 GB even when I restore only the test snapshot. Since the test snapshot has many tables truncated and data is less, I would assume that the the size of the .mdf file should be less than that for production snapshot. But that is not the case. Does sql server reserve space in the mdf file and hence it is the same size for both the versions?
Yes it does reserve space. You can see this in the create database page and later in the properties pages.
MDF = space reserved
bak = 8k pages with data
When the database is restored, it reads the size from sys.database_files. The pages are put back into the same relative place.
Unless you are really short of disk space, I'd leave it... but you can shrink the files if it makes you feel better
You are using (ballpark figures) 64,000 pages but have reserved 12,800,000
i think you need to run the following on your DB.
DBCC SHRINKDATABASE (UserDB, 10);

Resources