我們的品牌

Impact-Company-Logo-English Black-01-177x54

歡迎造訪施耐德電機全球網站

歡迎訪問我們的網站
		
我们今天能为您提供什么帮助?
How to change the location of database TempDB files Tempdb.mdf and TempLog.ldf in SQL 2008 and 2012 from default location ?

With use of SQL Server the size of database TempDB grows and logical drive C may be short of space. Default location is as shown in snapshot.

How to change the location of database TempDB files Tempdb.mdf and TempLog.ldf in SQL 2008 and 2012 from default location

To change the location take following steps.
Determine the  file names of the tempdb database and their current location on the disk.  Files used by the tempDB database is TempDB.mdf and Templog.ldf.
Use below SQL query to check the same.
SELECT name, physical_name AS Current Location
FROM sys.master_files
WHERE database_id = DB_ID(N'tempdb');
GO

Now use below SQL query in SQL server management studio to change the location of  file by using ALTER DATABASE as shown.

USE master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = 'G:\SQLData\tempdb.mdf');
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = 'G:\SQLLog\templog.ldf');
GO

How to change the location of database TempDB files Tempdb.mdf and TempLog.ldf in SQL 2008 and 2012 from default location

Make sure to create folders for the new locations first else the SQL query will give an error.  Cross verify as below that locations get changed.

How to change the location of database TempDB files Tempdb.mdf and TempLog.ldf in SQL 2008 and 2012 from default location

Delete Tempdb.mdf and Templog.ldf files from the old location.


施耐德電機Taiwan

探索更多
系列:
探索更多
系列:
  • 產品文檔
  • 軟體下載
  • 產品選型工具
  • 產品替代和替換
  • 幫助和聯絡中心
  • 尋找我們的辦公室
  • 取得報價
  • 施耐德電機社群
  • 人才招募
  • 公司簡介
  • 舉報不當行為
  • 無障礙
  • 新聞中心
  • 投資者
  • 專業洞察
  • 台灣施耐德電機學院
  • 綠色影響力落差調查
  • Schneider Go Green 2025
  • 隱私政策
  • Cookie通告
  • 使用條款
  • Change your cookie settings