Hi all:
How i can rename the logical name of a datafile?
Best regards
FernandoAssuming SQL Server 2000, you can do it using ALTER DATABASE (See Books Onli
ne for details).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Nano" <Nano@.discussions.microsoft.com> wrote in message
news:B717FD0B-E98A-4709-9BB7-3A4CC0DE0FC4@.microsoft.com...
> Hi all:
> How i can rename the logical name of a datafile?
> Best regards
> Fernando|||if you want to change the logical name and you're on sql2k...
alter database dbname modify file(name=oldname, newname=newlogicalname)
if you're on sql7, you could use this script.
-- Rename Logical name
-- Created by OJ Date: 05-24-00
--_--
Set quoted_identifier off set ansi_nulls on
Set nocount on
-- Allow system files to be updated
Exec sp_configure 'allow updates', 1
Reconfigure with Override
go
Declare @.dbname varchar(30),
@.newDataName varchar(64),
@.newLogName varchar(64)
Select @.dbname=rtrim(ltrim(db_name())_)
Select @.newDataName=@.dbname + '_Dat',
@.newLogName=@.dbname + '_Log'
Select 'The OLD logical name for ' + rtrim(filename) + ' is: ' + name from
sysfiles1 where fileid=1
Select 'The OLD logical name for ' + rtrim(filename) + ' is: ' + name from
sysfiles1 where fileid=2
-- Update dataName
Update sysfiles1
set name=@.newDataName
where fileid=1
-- Update LogName
Update sysfiles1
set name=@.newLogName
where fileid=2
Select 'The NEW logical name for ' + rtrim(filename) + ' is: ' + name from
sysfiles1 where fileid=1
Select 'The NEW logical name for ' + rtrim(filename) + ' is: ' + name from
sysfiles1 where fileid=2
set nocount off
go
-oj
"Nano" <Nano@.discussions.microsoft.com> wrote in message
news:B717FD0B-E98A-4709-9BB7-3A4CC0DE0FC4@.microsoft.com...
> Hi all:
> How i can rename the logical name of a datafile?
> Best regards
> Fernando
No comments:
Post a Comment