Waht Is Tempdb Database Used For? And How Can We Determine What Files Can Be Deleted From It?

Jun 25, 2007

Hi, all experts here,



Thank you very much for your kind attention.



Just found that my tempdb is always full whenever I run a query against a large database. Could please any experts here give me any advices on what is tempdb database used for and how to determine what files can be deleted from it?



I am looking forward to hearing from you and thanks a lot in advance.



With best regards,



Yours sincerely,



View 3 Replies


ADVERTISEMENT

Physical Files Can Not Be Deleted After Database Detached

Oct 10, 2007

I have detached the database via sp_detach_db in a job, (I was trying to use a job to detach the database, then make copies of the mdf file, then attach the databases as different copies, somehow the job failed due to file locked) I tried to delete the physical files, but they were still locked. I tried several times, two of them I was able to delete the mdf files, but not the ldf file. The other one both mdf file and ldf file can not be deleted. I was not able to see the database via Management studio.

Can anyone help?

Thanks

View 3 Replies View Related

SQL Server Admin 2014 :: Separate Data Files / Log Files / TempDB / Backups

Jan 9, 2015

I proposed on a new server that we separate Data Files, Log Files, tempDB, Backups, etc. onto separate LUNS on a SAN with High Speed Solid State Drives.I was told that with the new technology with solid state SAN's that it would decrease performance and that it did not work the same way as it did when you had RAID 5's etc.I thought that if things were cared out correctly by a SAN Administrator they would know how to configure for optimal performance.

View 2 Replies View Related

How To Attach Or Restore Db From .mdf And Ldf Files After Db Deleted

Aug 19, 2002

First, let me say that I have already reviewed information posted by experts within the chat area.

Someone completely deleted my SQL Server 7 database. I retrieved the .LDF and .MDF files from a network backup. Now I am trying to attach the database. I have tried this without creating an instance of the database by using the attach stored procedure to attache the .LDF and .MDF files I retrieved from the network backup. Also, I have tried it by creating an instance of the database and doing a detach of the newly created db .LDF and .MDF files and an attach of the .LDF and .MDF files I retrieved from the network backup. Neither of these approaches have worked.


Here is what I have tried in the Query Analyzer, but to no avail:


For the following example, I created a database instance called 'qarun_diamond_48_brett' with brand new .ldf and .mdf files and then tried to detach and then attach the .ldf and .mdf files from the network backup:

use master
go
sp_detach_db
'qarun_diamond_48_brett', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett_log.ldf'

Message: Usage: sp_detachdb <dbname>, [TRUE|FALSE]


use master
go
sp_detach_db
'qarun_diamond_48_brett', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett.mdf'

Message: Usage: sp_detachdb <dbname>, [TRUE|FALSE]


I tried the following attaches of the retrieved/recoverd .ldf and .mdf from the network to the newly created db instance. That didn't work, so I tried attaching to a db that had not yet been created.

use master
go
sp_attach_db
'qarun_diamond_48_brett2', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett2_log.ldf'

Message: Server: Msg 1801, Level 16, State 3, Line 1
Database 'qarun_diamond_48_brett' already exists.

If I use a different db name I get the following error:
Server: Msg 5105, Level 16, State 13, Line 1
Device activation error. The physical file name 'qarun_diamond_48_brett' may be incorrect.


use master
go
sp_attach_db
'qarun_diamond_48_brett2', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett2.mdf'

Message: Server: Msg 1801, Level 16, State 3, Line 1
Database 'qarun_diamond_48_brett' already exists.

I have also tried these statements wtih the EXEC sp_attach_db and EXEC sp_detach_db commands from within the Master db in Query Analyzer.

Any help would greatly be appreciated.

Thanks,

-Brett

View 2 Replies View Related

Manipulate The 'deleted Record' Flag On DBF Files

May 7, 2007

Hi,



I am using OLE DB provider for Foxpro (VFPOLEDB.1) to query DBF files. I need to migrate the content of these files to a SQL Server 2005 database.



These DBF files have some (actually a lot) records marked as deleted using the DBF 'deleted' flag. When I submit a SELECT command to the OLE DB Provider, it returns me all the non-deleted records from the file.



It is very Ok as long as the 'deleted' rows actually have no more business value, but in my case, I need to do some processing on them, and even to migrate their data.



What are the options available for me to be able to query and differentiate the 'deleted' records ?



Thank you in advance,



Bertrand Larsy

View 6 Replies View Related

Expanding Tempdb In A Device Prevents The Device From Being Deleted

Nov 17, 1998

I have a database in development in SQL Server 6.5 that needs to be occasionally deleted and rebuilt from a script when table structures are changed. I found that when very complex queries were performed, the 2 MB default size of tempdb filled up and returned errors, so I went to the Enterprise Manager to expand tempdb, learned that I had to first expand a device to expand tempdb into, and foolishly chose to expand tempdb into the same device space used by my application, instead of into one of the system databases. Now when I try to delete the device in preparation for its rebuild, the Enterprise Manager responds with an error message saying the device can't be deleted because it contains system tables. Is there any way to get the expanded portion of tempdb out of my application device so that the device can be deleted, without reinstalling SQL Server?

View 1 Replies View Related

SQL Server 2008 :: Count Number Of Files Deleted From Share Path?

Apr 23, 2015

SET NOCOUNT ON
Declare @daysOld int,@deletedate nvarchar(19) ,@strDir varchar(250)
declare @cmd11 nvarchar(2000)
declare @mainBackupDir varchar(2000),
@result1 nvarchar(max);

[Code] ....

View 1 Replies View Related

TempDB Log Files Are Filling Up.

Dec 28, 2006

What is the best way to fix issues with your log files in TempDB when you start to see them causing error msgs?

Thansk for your time.

View 2 Replies View Related

TempDB Files Gone Missing

Nov 25, 2013

I was in the process of migrating a server from one physical box to another. They are identical drive setups, same OS (2003), same SQL install (2005). Our server team did a 'PlateSpin', which copies the drives from one server to another, as long as the files are not in use. I did not reinstall SQL on the new box, i let the 'PlateSpin' tool copy everything over for me. I then stopped the SQL services on the old server and new server and copied over all of the system database (.mdf & .ldf) files. As soon as i started up the services on the new server, it looked great with one exception. The TempDB was only showing one datafile. When i queried sys.master_files, it was showing me 8 TempDB files. I tried restarting the services, but i still saw the same, only 1 file. I then tried to re-add TempDB files with the same name, but it would error saying they already existed. In turn, i could add new files with different names and they showed up fine. However, on a restart, they would not show up in the properties of the TempDB.

When i queried, sys.master_files again, i now had 16 Temp db files listed in the results. I deleted all but the original single file that was recognized out of the sys.master_files table and re-added the additional 7 files with he original names, restarted the service and then they all appeared.

View 2 Replies View Related

How To Drop One Of The Tempdb Files

Nov 23, 2005

Hi all, I have a tempdb that consists of 8 datafiles, tempdb_data_1 totempdb_data_8, each is 8GB. Now how can I drop 7 of them and leaveonly tempdb_data_1? Can this be done? Thanks a lot.

View 3 Replies View Related

SQL 2012 :: TempDB Data And Log Files On One SSD?

Mar 3, 2015

I'm having an argument with our infrastructure architect who has just gone and bought lots of SSD drives to use for our tempdb data and log files, sounds great doesn't it? There is a catch though, his plan is to add the disks to the two available slots in each blade in a RAID0+1 configuration, effectively giving you one usable drive, and adding both data and log files on to one disk.

I then pointed out that SQL Server best practice is to host tempdb data and log files on two separate drive to reduce contention. The architect then basically said that because this isn't spinning disk the issue of drive, r/w contention isn't an issue I don't agree with this and wanted to get some opinions from the community, I'm still advising that two separate disks should be used but someone just went and spent £80k ($150k) on SSDs and doesn't want to back down...

View 4 Replies View Related

TempDB Files On Root Of Drive

Sep 15, 2015

Documentation that supports the placement of Tempdb files on the root of a drive, i.e T: instead of T: empdb. I am positive this is not a best practice, but when challenged could not find any documentation that would support that view.

View 7 Replies View Related

How To Start SQL Server When Tempdb Files Were Relocated?

Nov 22, 2005

It's been a long time since I've tried this, but I have a SQL Server that needs to be restored (including master) to a server whose drives and corresponding folders match the source server, with the exception of tempdb. When SQL Server initially starts I believe it will fail since it cannot find tempdb. I just don't recall if it fails to startup or if it starts up reporting errors and recreates tempdb in the same location as master. Does anyone recall the steps needed to point SQL Server to the new location of tempdb?

Dave

View 1 Replies View Related

SQL 2012 :: Splitting TempDB With Multiple Files?

May 21, 2015

So we have new servers that are going to be installed with SQL 2012 and I'm debating the wisdom of splitting tempdb with multiple files.

I know it's a myth that performance automatically improves if you split it into a number of files based on processors, but I'm debating the wisdom of putting a file on each of my data / log file drives.

For instance, I have a server with a C: drive (OS), D: drive (Data for system DBs and install of programs - 458 GB), an F: drive for user DB data files (767 GB), and a J: drive for log files (255 GB).

Obviously no files are going on C:. I'm debating on whether or not we should even leave system DBs on the D: drive given in our current 2k8 servers, we end up with Memory.dmp files over flowing the D: drives as well as .cabs and other install / update files that tend to collect on that drive over the years.

But if we leave the system DBs on D:, I'm wondering if adding a second tempdb file to F: and a third to J: will improve query performance or not.

View 9 Replies View Related

Deleting Extra Tempdb Log And Data Files

Jul 20, 2005

We had someone create an extra data file and log file for tempdb. Sowe currently have two data files and two log files. Is it possible todelete the newly created data and log files? If I just delete thephysical files, I assume they'll get created as soon as SQL Servergets started back up. Any help would be great, since a single dataand log file for tempdb is my goal.Thanks much.sean

View 3 Replies View Related

TempDb - Moving / Adding Files And Resizing

Oct 23, 2015

Have a SQL2008R2 instance on a VM where the single .mdf for the tempDb database is located on a high contention disk.  I've managed to get another 60GB disk and thought it would be a good time to move the .mdf and also increase it's size and number of files. 

The server has 12 cores and after a bit of reading I've decided that it would be best just to have four files for this database as the 1 file per core (-1) seems to be disputed.  

-- Move the existing file to the new disk and rename it.
ALTER DATABASE tempdb MODIFY FILE (NAME='tempdev', FILENAME='E:SQLData empdb0.mdf');

-- Change the size to 1GB
ALTER DATABASE tempdb MODIFY FILE (NAME='tempdev', SIZE= 1048576KB, FILEGROWTH=5%);

-- Add three new files, all with the same size & growth
ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdev1', FILENAME = N'E:SQLData empdb1.mdf' , SIZE = 1048576KB , FILEGROWTH = 5%)
ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdev2', FILENAME = N'E:SQLData empdb2.mdf' , SIZE = 1048576KB , FILEGROWTH = 5%)
ALTER DATABASE [tempdb] ADD FILE ( NAME = N'tempdev3', FILENAME = N'E:SQLData empdb3.mdf' , SIZE = 1048576KB , FILEGROWTH = 5%)

-- Now restart the instance.
 
Also, what are peoples thoughts on percentage growth for tempDb?  I've read that it's not recommend and yet it seems to be the norm.

View 4 Replies View Related

Setup And Upgrade :: Number Of TempDB Files

Aug 24, 2015

My server has two 8 core processor. Should I use 8 or 16 data files for Tempdb?

View 4 Replies View Related

SQL 2012 :: Alerting When Tempdb Files Have X% Free Space?

Aug 13, 2014

I have a tempdb split into 4 files (5 if you include the log).

Autogrowth is disabled on the mdf/ndf files so that they can be used round robin (1 file per logical CPU).

Is there a way to be alerted when there is x% of free space left?

I know hwo to check the free space via t-sql but want to be able to be alerted. I could run a sql job that reports the free space and send a database mail message if under x% but wondered if there was a built in (or better) method?

I also have SQL Sentry.

SQL 2012 Standard

View 9 Replies View Related

SQL 2012 :: Cannot Create Extra Tempdb Files Because They Already Exits

Feb 23, 2015

I was in the process of creating additional TempDB.ndf files, and received an error saying they already exist. I checked the location and it was empty, nothing to see here. So I looked in sys.master_files and there are several tempdb files listed in various locations, all of which come up empty.

So the files are listed as online in sys.master_files, but they do not exist on the server. I restarted SQL services but it did not change anything.

View 3 Replies View Related

How Do I Prevent An Insert Into Statement To Increase Tempdb Data Files So Much

May 6, 2008

I'm running this procedure which insert into table_name(id, name.....) select id, name.... from table_name. For some reason the tempdb data file grow up to 200GB. The tempdb is set to expand unrestricted by 10%. How can I prevent that from hapening? Thanks.

View 5 Replies View Related

SQL 2012 :: TEMPDB High Avg Write Wait Time On Data Files

Apr 15, 2014

I am currently investigating aa high avg write time ms issue (145ms) which seems to be only occuring on the tempdb data files.I have followed the recommended setup of TEMPDB in that

1. Data files = number of physical cores
2. Data files and logfiles are on separate partitions away from the other databases.
3. Tempdb is presized and no incremental file increases look like they are happening with frequency.

We have sharepoint 2012 setup on other sql servers and with TEMPDB setup following the same guidelines, with far more Sharepoint activity on a similary specified hardware which is why its confusing.FileIO auditing on the partitions themselves shows that the FileIO is very fast on the partitions that the tempdb data file which leads me to beleive that Sharepoint may be the culprit perhaps due to excess use of tempdb with operations taking a long time to resolve.

View 3 Replies View Related

SQL Server 2008 :: Count Number Of Backup Files Deleted From A Default Backup Location

Mar 13, 2015

I've written a custom script to delete backup files from location. But unable to modify now to count the number of files are deleted. How to modify the script...

/* Script to delete older than N days backup from a specific directory */

USE [db_admin]
GO
IF OBJECT_ID('usp_DeleteBackup', 'P') IS NOT NULL
DROP PROC usp_DeleteBackup
GO

[Code] .....

View 2 Replies View Related

How To Determine Last LSN For Database

Feb 13, 2008



What is the most reliable way to determine the last LSN of a database? I've looked in sys.database_files to no avail. I've also looked in msdb.dbo.backupset which is accurate but only based on backups already performed not the current state of the database.

-joe

View 5 Replies View Related

To Know Who Deleted The Database

Dec 11, 2000

Is it possible to know that who has deleted the database

Thanks in advance

View 2 Replies View Related

Deleted Database

Jan 21, 2005

Our past CIO deleted a SQL Server database because he didn't know what it was or if we needed it. Guess what we do! We were able to undelete the backup files but when we try to restore from it we get the error "No a valid backup" Any ideas?

Thank you for any help. :eek:

View 2 Replies View Related

Need To Determine If Records Are Already In Database

Feb 21, 2001

Problem: I can add 4 items to a SQL 7.0 database but I need to redirect the user if all 4 items exist in the same Record elsewhere in the Database.

Clearly I need some kind of statement like "if category1 = var1 AND category2 = var 2 AND..." but don't know where to put it.

Code:

strSQL = "SELECT * FROM tblUserQuarter"

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn,adOpenStatic , adLockOptimistic

'Insert choices from report.asp into tblUserQuarter
objRS.AddNew
objRS("cboFY") = Request.Form("cboFY")
objRS("Quarter") = Request.Form("Quarter")
objRS("ID") = Request.Form("ID")
objRS("Report") = Request.Form("Report")
objRS.Update

objRS.Close
Set objRS = Nothing
objConn.Close
set objConn = Nothing

View 1 Replies View Related

How To Determine Size Of Database

Feb 25, 2015

I ran a query to see how big my database on my SQL Server is and do not understand the metrics. I want to see how much of my 10GB database is left.

database_namedatabase_sizeunallocated space
ANTHEMQ 6521.06 MB243.55 MB

reserveddata index_sizeunused
1332304 KB1328168 KB1800 KB 2336 KB

View 3 Replies View Related

How Can I Determine The Size Of A Database?

Mar 8, 2007

Simple question...

When I use the full version of SQL Management Studio, I can run a report to view the size. How can I do this with SQL Mgmnt Express?

View 1 Replies View Related

Determine Date Database Was Last Used ?

Jun 15, 2006

Hi There

I am trying to establish the date a database was last used.

At first i checked out sp_helpfile and sysfiles to see if there was a date last modified, i also tried using xp_cmdshell to check the date on the actual .mdf or .ldf on the o/s but if the file has not grown the date will be the create date.

I need to establish the date a database was last used, either the last time someone logged into it or the last time any sort of command was run against the database, i cannot use sysprocesses as there are no connections to the database, so i need to determine the last time there actually were any processes run against this database.

And i need to use tsql, checking audit logs etc is not viable, can anyone help ?

Thanx

View 6 Replies View Related

Records Don't Get Deleted From The Database!

Sep 17, 2007

I am using this code to delete records from a table in the database that has two fields (both are primary keys) I am not getting any error, but nothing gets deleted. Thanks for the help.
Code:protected void btnRemove_Click(object sender, EventArgs e)
{
 
Remove();Response.Redirect("RegisteredCompanies.aspx");
 
}protected void Remove()
{
//update database with filename
//Save Changes
connection.Open();using (SqlTransaction trans = connection.BeginTransaction())
{
try
{ SqlHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, "spRemoveCompany", new SqlParameter("@Userid", getGdUserID(Profile.UserName)),new SqlParameter("@BusinessID", getBusinessID());
}catch (Exception err)
{
// throw exception
trans.Rollback();
 lblStatus.Text = "An error has occurred in the delete process. Please try again.";
}
}
 Here is the stored procedure:ALTER PROCEDURE [dbo].[spRemoveCompany]
 
 
@Userid uniqueidentifier OUTPUT,
@BusinessID uniqueidentifier OUTPUT
 
 
 
ASDELETE FROM Associations2 WHERE Userid = @Userid AND BusinessID = @BusinessID
 
RETURN

View 4 Replies View Related

Deleted The Database But Have A Backup .

Apr 9, 2007

i backed up the database d1 and deleted it off my sql server.
when i innitiate the sql server instante is supposed to run the d1 DB. But since i deleted it, it pops up an error. How can i fix it?

View 4 Replies View Related

Default Database Deleted

Sep 3, 2007

Dear All,
i'm using sql server 2005.
I've one default database named testdb. unexpectedly that was deleted. now i was unable to connect to the server. what is the solution for this

Vinod
Even you learn 1%, Learn it with 100% confidence.

View 2 Replies View Related

Recover Deleted Database

Oct 5, 2007

I have accidentally deleted a Database from SQL server 2005 instance. Is there any chance for me to recover the Database. If yes do let me know the method.

Thanks in advance
Mrinmoy

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved