Counter of Festivals

Ashok Blog for SQL Learners and Beginners and Experts

Wednesday 7 June 2017

How to Change Logical Name of Database in SQL Server

How to Change Logical Name of Database in SQL Server


Now we want to change from TestMoveMDFLDF to TestMoveMDFLDF_Data

Method 1:

select * from sys.database_files where name = 'Logicalname' and type_desc='ROWS'

select * from sys.database_files


see through query of logical name as see below


Method 2:

EXEC SP_HELPDB dbname



Method 3:

Logical and physical name through below query

Select sd.name as DatabaseName,sm.Name as logicalname,physical_name from sys.master_files sm
join sys.databases  sd on sm.database_id=sd.database_id
where sd.name='TestMoveMDFLDFSTD'



We should need to execute below query to alter new logical name see below


ALTER DATABASE TestMoveMDFLDFSTD
            MODIFY FILE (NAME=N'TestMoveMDFLDF', NEWNAME=N'TestMoveMDFLDF_Data')​




EXEC SP_HELPDB dbname

You can see Logical name is changed






that is logical name is changed it


No comments:

Post a Comment