Change Logical Name In Script
Aug 9, 2006
I'm trying to restore about 70 databases onto a new SQL server and
wanted to script the creation and restore. I've done the creation with
no problems, but on the restore, the logical names (of the original
data) are all over the place and were historically wrong.
So, when I use the script below... I've had to work out the Logical
name for the data and the log file and alter the script accordingly.
Creation
------------
Create Database MyDatabase ON (NAME = MyDatabase_data, FileName =
'D:DatabaseMSSQLDataMyDatabase.mdf') LOG ON (NAME = MyDatabase_log,
FileName = 'D:DatabaseMSSQLDataMyDatabase.ldf') COLLATE
SQL_Latin1_General_CP1_CI_AS
Restore
-----------
RESTORE FILELISTONLY
from disk =
'D:DatabaseMSSQLBACKUP2006-08-07MyDatabase_db_200608072100.BAK'
restore database MyDatabase
from disk =
'D:DatabaseMSSQLBACKUP2006-08-07MyDatabase_db_200608072100.BAK'
with REPLACE,
MOVE 'SomeOtherRubbish_Data' TO
'D:DatabaseMSSQLDataMyDatabase.mdf',
MOVE 'SomeOtherRubbish_Log' TO
'D:DatabaseMSSQLDataMyDatabase.ldf'
go
When I then look at the properties of the database, it shows the old
convention which I don't want.
So, even though I've been neat creating the database, it gets
overwritten with the odl rubbish name. How can I change the logical
name so that I can have a nice and neat naming convention ?
Oh, Yes I know I added the collation when creating the database, but
that's another thing that we need to address at some point.
Thanks in advance
View 2 Replies
ADVERTISEMENT
Jan 18, 2000
I cannot find the answer to this: how do you update the logical file name for a database? Restore database "Alpha" over "Beta" specifying WITH MOVE parms allows "Alpha"'s physical files to overlay "Beta"'s, but now "Beta"'s logical file names are "Alpha_Data" and "Alpha_Log".
Updating sysfiles directly gives back a 270; "Get outta here!"
Can this not be done?
View 2 Replies
View Related
Jul 20, 2005
Hi,Is there an option (stored procedure) or whatever to change to logical nameof the databasefile and the database log file ?Arno de Jong, The Netherlands.
View 1 Replies
View Related
Aug 23, 2006
A database was set up as a test database and then the database name changed but the logical and physical filenames still have test in their name - obviously not a good idea. I have tried to change the physical file name but get the error message that the physical file name cannot be changed once the database has been created. I have also tried detaching the database and renaming the mdf and ldf files but these could not be re-attached so had to revert back to the original names.
View 2 Replies
View Related
Feb 13, 2008
Hi all
We generally modify the logical name of a data file or log file from the vendor defined to our standard name. Is there any impact that you know about this? If you have 2 seperate database and accidently you have 2 same logical name .. I dont' think that will be an issue ... correct?
ALTER DATABASE XXX_UAT
MODIFY FILE (NAME = 'mdd_Data', NEWNAME = 'XXX_UAT_Data')
GO
ALTER DATABASE XXX_UAT
MODIFY FILE (NAME = 'mdd_Log', NEWNAME = 'XXX_UAT_Log')
GO
View 1 Replies
View Related
Jul 17, 2007
Hi,I want to change the logical name of the database. My database name and.MDF has the same name, but the logical name is different. Willchanging it impact anything?--sharif
View 1 Replies
View Related
May 21, 2008
I have a query. on my search page i have a number of textboxes e.g. title, subtitle, ISBN where users can enter a search string and when they click on a button the data is displayed in the gridview below.
my query seems to be bringing up the right records but with some additional records into the gridview. I have tried the same query within the SQL server management studio and it brings back two records like indicated but within my aspx page it brings back 6 additional records that have no relevance to the query. Im quite baffled as to why this is happening and i have debugged but nothing comes to light.
my code in my aspx page is as follows:
public void BindData(){String _BookID = TxtBookID.Text;String _Title = TxtTitle.Text;String _Subtitle = TxtSubtitle.Text;String _ISBN = TxtISBN.Text;String AuthorFName = TxtForename.Text;String AuthorLName = TxtSurname.Text;
SqlDataAdapter ad = new SqlDataAdapter("SELECT Book_ID, Book_ID_Internal AS [Book Internal ID], Title, Subtitle, ISBN, Edition, Publication_Date AS [Published Date] FROM Book WHERE Book_ID_Internal = '" + _BookID + "' OR Title = '" + _Title + "' OR Subtitle = '" + _Subtitle + "'", conn);DataSet ds = new DataSet();ad.Fill(ds, "Book");if (ds.Tables[0].Rows.Count == 0){//if there are no rows returned-state in the gridds.Tables[0].Rows.Add(ds.Tables[0].NewRow());GridView1.DataSource = ds;GridView1.DataBind();int columncount = GridView1.Rows[0].Cells.Count;GridView1.Rows[0].Cells.Clear();GridView1.Rows[0].Cells.Add(new TableCell());GridView1.Rows[0].Cells[0].ColumnSpan = columncount;GridView1.Rows[0].Cells[0].Font.Italic = true;GridView1.Rows[0].Cells[0].Text = "No Records Found";}else{GridView1.DataSource = ds;GridView1.DataBind();}}
if i input the same query into SQL management studio:
SELECT * FROM Book WHERE Book_ID_Internal = 'ITD 450' OR Title = 'HTML 4.0'
it returns two records which is correct.
Can anyone see where i am going wrong?
View 4 Replies
View Related
Jun 19, 2002
Hello,
Is there any way to change the logical filename of exsiting database
Thanks
Lara
View 1 Replies
View Related
Nov 7, 2000
In the database properties screen, there are four tabs: General, Transaction Log, Options, Permissions. In the General Tab, it lists four columns: File name, Location, Space Allocated, File Group.
The string in the File name column has a value such as MY_DATABASE_DAT, whereas the Location column has a value like D:mssql7dataMY_DATABASE.MDF.
The Location value is clearly the Windows file name. The "File name" (which I have seen called the "logical file") is a mystery to me. What is it used for? How can it be changed? Is there a problem if two different databases have the same "logical file" name?
(For example, if you do sp_detach_db, copy the file to another place and then sp_attach_db the new file to another database name, you have two different databases with the same "logical file" name.)
Much thanks to anyone who can shed light on this.
View 1 Replies
View Related
Jul 5, 2000
Hi everyone,
I have a database (xyz) one Machine A. On the same machine I want to create a copy of the (xyz)database with different name(xyz_1). When I restore with move option it will restore but the thing is logical file names of xyz and xyz_1 are same. I know I can change these file names by manupulating the system table.
My question is If I didn't change the logical file names of database xyz_1(new). Is there any problems or issues may arise.
Thank you,
Dindu.
View 1 Replies
View Related
May 4, 2007
The organisation I'm working for has SQL Server 2005 merge replication up and running on 11 servers in 3 different countries.
Ocasionally we experience problems caused by rows in a logical record relationship being replicated between servers in the wrong order, i.e. an attempt is made to insert child rows before the parent. I am not able to reproduce this behaviour on my test servers.
Has anyone else experienced this problem?
View 16 Replies
View Related
Jun 28, 2007
We have a progress database that we use RS on. The "status" field (active/inactive) is a logical field (true/false). When doing the SQL how do I specify that I want only active records (value = true).
View 1 Replies
View Related
Apr 4, 2001
How to rename logical name for transaction log ?
thanks
View 2 Replies
View Related
Oct 24, 2001
Pros,
I would like to change the logical filenames for a database on my test server. I know this is done with ALTER DATABASE, but I'm not sure of the exact syntax. Can anyone help?
rb
View 3 Replies
View Related
Mar 29, 2000
Hi All,
I've been asked to trouble shoot an installation where many stored procedures are performing poorly. Upon examination I've found that the queries in these procs consume a large volume of logical IO (table scans etc). I'm trying to show that this could cause poor performance of the stored procedures as well as degredation of the server as a whole - but I cant find any suitable counters in Perfmon.
Anyone help?
Jim
View 1 Replies
View Related
Apr 24, 2000
Hi
Every one
One thing i found out that my 2 databases in server A
Has same logical file name .
I have try to change the name but it is not allowing me to change.
I had refer BOL it says that we should have unique logical file name in a server for each database.
Question i have is does it going harm me i don't know this
if any one u know please suggest me.
Problem I already started getting is I do backup 5 small databases of 10 to 20 mb in one tape only. The 2 database which has same logical file name out
of which one is getting copied & another is not ,All other database it backup
perfecly.
But at the same time in a hard disk if i take backup of this database in a same device it works perfecly so i don't understand where the problem is
If any has any idea please suggest me
Thanks
Nirmal.
View 1 Replies
View Related
Mar 14, 2003
I'm moving a database (XYZtest) from the test server to the production server via sp_detach/sp_attach. I want the logical file names to be XYZ_data, rather than XYZtest_data, etc. I can easily rename the disk files, but how do I rename the logical file names?
Thanks,
Al
View 1 Replies
View Related
Apr 24, 2002
Hi,
Does anyone know how to change the logical file name of a database?
Appreciate any help.
Steve
View 1 Replies
View Related
Sep 5, 2001
Is there any SYSTABLE or table from where I can get the backup device logical name.
Thanks,
-Rajesh
View 1 Replies
View Related
Nov 30, 2005
I have a view based on few tables okay
I have a query that gives me document details of various revisions
Now i also get the latest rev of those if i use a MAX() in my Query
Now a case where i have say
Docu Numb - Revi - Received Date
Document1 - rev0 - 10/2004
Document1 - rev1 - 11/2004
Document1 - rev2 - 12/2004
Document1 - rev3 - 01/2005
Document1 - rev4 - 02/2005
Document1 - rev5 - 03/2005
Document1 - rev6 - 04/2005
Document1 - rev7 - 05/2005
If i query for latest it gives Document1 - rev7
And if i filter for a month of 12/2004
If i query for latest it should give Document1 - rev2
Now i need to get a filter with latest as rev2,
plus i also need as a indication of actual latest as rev 7
using a query
How do i do that ...
Coz when i use filter for a month and Max then it
does not consider rev7 for that filter and skip the record
and if i try to filter only as per month .. i get a wrong info
as latest rev2 which is not a true info as per database records.
May i possibly get both ... filtered info as per specific month and
also a rev info as what is the latest for a spec document.
Just i need to know is that possible .. in SQl using a query
Any more info needed please mail me on
neeraj.jariwala@gmail.com
Life is beautiful ... When you smile ...
View 1 Replies
View Related
Jan 18, 2007
Hi,
we consistently have logical page errors on one of our SQL Servers.
The output from CHECKDB is shown below. Any ideas why this keeps happening. We recently replaced the disk thinking this would solve the problem.
DBCC results for 'TMP_tbl_Pay_Totals'.
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:391469) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
AND later on
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:398376) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:398377) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:398378) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:398379) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:398448) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:398449) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:398450) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:398451) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
Server: Msg 2533, Level 16, State 1, Line 1
Table error: Page (1:398452) allocated to object ID 1412968160, index ID 0 was not seen. Page may be invalid or have incorrect object ID information in its header.
Server: Msg 2533, Level 16, State 1, Line 1
Final bit
CHECKDB found 0 allocation errors and 11 consistency errors in database 'ISS'.
repair_allow_data_loss is the minimum repair level for the errors found by DBCC CHECKDB (ISS ).
Any help or ideas much appreciated.
View 4 Replies
View Related
Jul 31, 2007
Hi how do I select the current logical database name using a select statement.
View 8 Replies
View Related
Aug 16, 2007
I have a table with 50% Logical Scan Fragmentation. [ according to Dbcc Showcontig (myTable) ]
Why after running DBCC INDEXDEFRAG (myDB,myTable) does it still sit at 50%.
Why isn't it lower?
View 7 Replies
View Related
Sep 5, 2007
Hi Friends,
I have three tabels A,B,C having relation of primery & forign key, and i want to fetch data from all three.
In case if only A have the values and B & C dont have values, then also i want values.
But my simple sql statement dose not show any data, if B & C dont have values.
Any one tell me that how to fetch data from this type of Situation???????
pls
Thanks,
gs
View 3 Replies
View Related
May 19, 2008
hi we are in the process of developing a project and we r at the initial phase i.e. at the analysis phase and we have been discusssing on what is physical and logical database design. can any body send any links or articals on this will be hightly appreciated.
View 1 Replies
View Related
Apr 25, 2002
The many that I have spoken to all are clueless on this one. Thanks in advance for the right solution!
The insert trigger I created works fine (well, nearly fine), except that AFTER the first insert operation (ie second, third etc), it always produces the correct results BUT FOR THE PREVIOUS INSERTED ROW. It is as if there is a latency of one row in the temp table INSERTED.
I would greatly appreciate a 'why', and more importantly, a 'how to fix it' for this problem.
If you need to look at the code, a NOTEPAD file is attached.
Much appreciated
--start trigger--
create trigger UpdateAffiliateEarnings
on Orders
for insert, update
as
--declare variables
declare @ProductType varchar(15),
@AffID int,
@Earnings money,
@CurrentEarnings money,
@AffTotalEarnings money,
@AffTotalPayments money,
@AffOutstandingBalance money
--check existence of affiliateid, and for product type
select @AffID=AffID, @ProductType=Source
from Orders
where AffID IS NOT NULL
--get relevant information
if @AffID IS NOT NULL
begin
if @ProductType = 'FLOWER'
begin
select @Earnings=CONVERT(money,ChargedAmount*CommissionRa te)
from Orders o,FlowerOrder t,Commission c
where o.OrderID = t.OrderID
and t.CommissionID = c.CommissionID
and PaymentConfirmedYN='YES'
end
if @ProductType='PHONE'
begin
select @Earnings=CONVERT(money,ChargedAmount*CommissionRa te)
from Orders o,PhoneOrder t,Commission c
where o.OrderID = t.OrderID
and t.CommissionID = c.CommissionID
and PaymentConfirmedYN='YES'
end
--update Affiliate account
--get totals to update
select @CurrentEarnings=AffTotalEarnings, @AffTotalPayments=AffTotalPayments
from Affiliates
where AffID=@AffID
--calculate new totals for affiliate account
set @AffTotalEarnings=@CurrentEarnings+@Earnings
set @AffOutstandingBalance=@AffTotalEarnings-@AffTotalPayments
--update affiliate account to new totals
update Affiliates
set AffTotalEarnings=@AffTotalEarnings, AffOutstandingBalance=@AffOutstandingBalance
where AffID=@AffID
--roll back the transaction if there is an error
if @@ERROR !=0
rollback tran
end
-- end of trigger --
View 1 Replies
View Related
Apr 10, 2001
Hello All,
I am facing problem with Logical File Name while restoring database. I am taking a backup of ABC database from Server1 in abc.bak file.
Then I am creating new database XYZ on Server2. Server1 and Server2 are not connected to each other in anyway, since both servers belong to different companies. Here on Server2 I want to restore backup of abc.bak on XYZ database. I select restore from Device, and on option tab I am selecting Force restore over existing database, in the below option I am specifying current Data & log file path for Move to physical file name.
But Logical file name shows ABC names, but if I tried to change those to XYZ names then restore fails. But if I keep ABC names then it works.
Is anybody knows how to over come this Logical Name issue?
Many thanks in advance….
Regards,
Santosh
View 1 Replies
View Related
Dec 22, 2000
Hi Everybody,
One of my friend asked me "How do we reduce the query logical, scan reads
in SQL Server?".
I really don't know, how to answer him.
Can anybody explain me regarding this.
thanks,
Srini
View 2 Replies
View Related
Mar 9, 2000
Is there a way to rename the logical file for a database. For example, if I am moving a development database into production, I can use backup - but the backup takes the logical file names of the database and puts it into my production server. Now I have a production database with "dev_data1" for a logical file.....Can I change that name....?
Thanks!
Dean
View 3 Replies
View Related
Sep 22, 2000
Hi all -
Quick question... I want to move all my non-clustered indexes to their own seperate drive array. How would I accomplish this?
Do I just add the filename at the end of the statement like you do in Oracle? (EXAMPLE: CREATE INDEX IDX_Cls_Code on dbo.Class(Code) on secondary.ndf)
If this isn't correct, can someone please post the correct syntax?
Thanks!
Rich
View 1 Replies
View Related
Jul 8, 2005
HI guys, long time since I've been here ...
Anyway, I have a question and hope to receive some suggestions.
We have a cluster installation of SQL 2000 Ent SP3a and we had a logical drive Y: on a second incative node: N2. SQL Right now is running of the active node: N1. We moved the Y: drive from Node N2 to the N1 one and it's fully functional and healthy. The only thing SQL doesn't see it. So ti has to be restarted.
Is there a way to refresh a list of logical drives on SQL without having the service to be restarted? (it's not an option for us meantime, it's our prod env.)
Any suggestions appreciated.
Thx
Dim
View 7 Replies
View Related
Aug 5, 2005
Are they're any real disadvantages or advantages in having 1 massive disk partioned to create 2 logical drives (not including the C drive) and separating the SQL Database File & Transaction Log so that it doesnt reside on the same logical drive?
After all, it is still a single disk.
thanks.
View 3 Replies
View Related
Aug 3, 2004
Does anyone know if MS SQL can't process a "select * from deleted" from within a cursor that's embedded in a trigger? I'm getting an error when I run this...
DECLARE check_contact_fields CURSOR
FOR SELECT field_id, column_name FROM contacts_fields
OPEN check_contact_fields
FETCH NEXT FROM check_contact_fields INTO @field_id, @column_name
WHILE (@@FETCH_STATUS = 0)
BEGIN
set @SQL = 'select ' + @column_name + ' into ##DeletedData from deleted'
exec sp_executesql @SQL
set @SQL = 'select ' + @column_name + ' into ##InsertedData from inserted'
exec sp_executesql @SQL
if (select * from ##DeletedData) <> (select * from ##InsertedData)
select * from ##InsertedData
FETCH NEXT FROM check_contact_fields INTO @field_id, @column_name
END
CLOSE check_contact_fields
DEALLOCATE check_contact_fields
drop table ##DeletedData
drop table ##InsertedData
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'deleted'.
TIA
View 14 Replies
View Related