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 Online 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
> Fernandosql
Showing posts with label regards. Show all posts
Showing posts with label regards. Show all posts
Friday, March 23, 2012
Rename database
Hi,
Is there any easy way to rename a database?
It can be done using SQL script or just
Enterprise Manager.
I'm using SQLServer 2000
Regards
Miroomust use T-SQL script, two means:
1.sp_renamedb dbold, dbnew
2.ALTER DATABASE dbold MODIFY NAME=dbnew
"Miroo_news" <miroo@.USUNTO.poczta.fm> wrote in message
news:bm09qr$78l$1@.atlantis.news.tpi.pl...
> Hi,
> Is there any easy way to rename a database?
> It can be done using SQL script or just
> Enterprise Manager.
> I'm using SQLServer 2000
> Regards
> Miroo|||U¿ytkownik "Henry" <qiuliang@.163.net> napisa³ w wiadomo¶ci
news:OyD5KTWjDHA.684@.TK2MSFTNGP09.phx.gbl...
> must use T-SQL script, two means:
> 2.ALTER DATABASE dbold MODIFY NAME=dbnew
Thank you, it works OK.
Regards,
Miroo
Is there any easy way to rename a database?
It can be done using SQL script or just
Enterprise Manager.
I'm using SQLServer 2000
Regards
Miroomust use T-SQL script, two means:
1.sp_renamedb dbold, dbnew
2.ALTER DATABASE dbold MODIFY NAME=dbnew
"Miroo_news" <miroo@.USUNTO.poczta.fm> wrote in message
news:bm09qr$78l$1@.atlantis.news.tpi.pl...
> Hi,
> Is there any easy way to rename a database?
> It can be done using SQL script or just
> Enterprise Manager.
> I'm using SQLServer 2000
> Regards
> Miroo|||U¿ytkownik "Henry" <qiuliang@.163.net> napisa³ w wiadomo¶ci
news:OyD5KTWjDHA.684@.TK2MSFTNGP09.phx.gbl...
> must use T-SQL script, two means:
> 2.ALTER DATABASE dbold MODIFY NAME=dbnew
Thank you, it works OK.
Regards,
Miroo
Subscribe to:
Posts (Atom)