Alter Database With Remove File Clause

Apr 4, 2001

I'm attempting to alter a database by removing one of two log files. I have truncated both log files successfully and the database has no processes but I get an error stating file cannot be removed because it is not empty. Help

View 2 Replies


ADVERTISEMENT

Alter Database File Extension

May 14, 2008



Hi,

I'm trying to change the file extension of one of the database files of a big database that contains 10 years of EPOS data.
When this file was created, at the beginning of 2008, with the following script:

USE [Live]


ALTER DATABASE [Live] ADD FILE (NAME = 'Live_2008',

FILENAME = €˜E:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataLive_2008') TO FILEGROUP [2008]
the .ndf file extension was not added to the filename. So the file now has a file type of "File", instead of "SQL Server Secondary Data File"
I tried, in a test environment, to bring the database offline, change the filename to "Live_2008.ndf" and bring the database back online, but it gives me an error message saying that "cannot open the Live_2008 file", i'm guessing because it's looking for "Live_2008" and it finds "Live_2008.ndf" instead.
This file is quite big (5Gb) and I cannot afford to risk to lose any data.
The situation is complicated even further by the fact that it seems that a partition for 2008 does not exist.
How can I find out what data this file contains?
Is it going to be an issue if I leave the file like that?
Thanks

View 3 Replies View Related

SQL Server 2008 :: ALTER Database To Modify Log File

Jun 25, 2015

We are running into the following error while changing a column data type from nvarchar (1200) to varchar(8000)
"Msg 1105, Level 17, State 2, Line 1

Could not allocate space for object 'dbo.TBL1 '.'PK_CL_ID' in database 'Client01' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.

The statement has been terminated."

Now tried to change the filegrowth of the log file to unlimited

ALTER DATABASE Client01
MODIFY FILE ( NAME = Client01_log, MAXSIZE = unlimited);

The query executes without error but I do not see the auto growth as unrestricted. It's still 2GB

View 6 Replies View Related

SQL Server 2014 :: Alter Database Modify Log File

Nov 6, 2015

I can run this command to make changes for 1 DB USE [master]

GO
ALTER DATABASE [DBName] MODIFY FILE ( NAME = N'Name_log', FILEGROWTH = 10000KB )
GO

Is it possible to create a script which changes log file size to let's say 100MB for all DBs in all servers instead of running the above command by logging into each server? We have about 200 servers and close to 3000 DBs.

View 2 Replies View Related

Using ALTER To Remove An IDENTITY Setting?

Mar 9, 2001

Hi,

I have been trying to figure out how to use ALTER TABLE/ COLUMN to modify a column from an IDENTITY column to one which is not an IDENTITY column.

I would like to do this so that I could add another column (using ALTER) and set it as the IDENTITY column.

Any thoughts?

Your help is much appreciated,
-Scott

View 1 Replies View Related

Cann't Remove Data File From User Database

Mar 15, 2004

We are running SQL server 2003 with SP3. I'm trying to
shrink a data files with the emptyfile option so I can
eventually remove the file using the alter database
command. However, I get the following error message when I
run the alter database command:

Error: the file PRADATA4 cannot be removed because it is
not empty.

The file that I'm trying to remove still has 62 extents on it.
I looked MS Knowledge base 254253 and 279511 on this problem but they say it is corrected by SQL server 7.0 with service pack 3.
commands that I'm running are as follows:

1) USE PRA
DBCC TRACEON(8901)
DBCC SHRINKFILE ('PRADATA4', EMPTYFILE)
DBCC TRACEOFF(8901)

2) USE PRA
GO
ALTERDATABASE PRA
REMOVE FILE PRADATA4
GO

Can anyone help?

Thanks

View 8 Replies View Related

Remove Certain Words From ORDER BY Clause

May 22, 2008

Hi,I'm trying to remove certain words from my Order clause. For example on iTunes they have removed the word 'The' from the start of artist names so that all the bands that start with 'The' don't appear grouped together. I'm trying to do a similar thing with University names so that all universities which begin with 'University of' or 'The' don't appear together.Is this possible?Thanks for your help!,Curt.

View 8 Replies View Related

SQL Server 2008 :: How To Remove Group By Clause

Mar 5, 2015

SELECT DISTINCT

'Banquets - All Day' as revName,
SUM(t.c_items_total) AS Banquet_Total,
SUM(t.cover_count) as Total_Covers,
-- (t.c_items_total) / (t.cover_count) as AvgPer_Cover--

[Code] ....

The output needs to be grouped by the t.c_items_total...I just need the avg per cover (person) / items_total.

View 4 Replies View Related

An Attempt To Attach An Auto-named Database For File (file Location).../Database.mdf Failed. A Database With The Same Name Exists, Or Specified File Cannot Be Opened, Or It Is Located On UNC Share.

Sep 2, 2007

Greetings, I have just arrived back into the country (NZ) and back into ASP.NET.
 I am having trouble with the following:An attempt to attach an auto-named database for file (file location).../Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
It has only begun since i decided i wanted to use IIS, I realise VWD comes with its own localhost, but since it is only temporary, i wanted a permanent shortcut on my desktop to link to my intranet page.
 Anyone have any ideas why i am getting the above error? have searched many places on the internet and not getting any closer.
Cheers ~ J
 

View 3 Replies View Related

How I Remove Records From The Log File

Oct 20, 2001

I have SQL Server Standart Edition and ý have a database, MDF file size is 650 MB, log file size is 1,23 GB

I tried to shrink the log file but i didnt shrink, I wanr to remove all records from the log file

How I remove records from the log file I want to shrink this file to 1 or 2 MB
Please help me

View 1 Replies View Related

Sysaltfiles , How Can I Remove A File

Jul 28, 2004

I'm taking the Administration of a DB wich it has on system table sysaltfiles some leftoff files that are not being used anymore on TempDB,

how can i remove them ? Every time i restart the SQL Service it tries to open those files on sysaltfiles..

I tried ALTER DATABASE tempdb remove file XXXX , it did not work...

I got this error:

ALTER DATABASE failed. Some disk names listed in the statement were not found. Check that the names exist and are spelled correctly before rerunning the statement.

View 1 Replies View Related

Granting Permission To A Database User To Alter Database Role

Sep 5, 2006

I want a database user to be able to alter login, database user and database role from my application. so, i assigned that user to sccurityadmin server role, db_accessadmin and db_securityadmin database roles....By now, the user can add or remove login and database user. However, the user cannot add or remove any database role membership. What am I missing here?? What should I do so that the user can create, and alter database roles in the database??

View 1 Replies View Related

SQL Security :: ALTER DATABASE Failed Because A Lock Could Not Be Placed On Database

Jul 20, 2015

I have a script that automates some db drop/restore operations and bringing the database to single user mode is part of it: ALTER DATABASE ... SET SINGLE_USER WITH ROLLBACK IMMEDIATE...I want this to executes under a login, that has restricted privileges, so I've created a login and granted it a dbcreator role + ALTER ANY DATABASE privileges.

Problem: When I run the script against a database with an active/sleeping connection:It fails when using the restricted login: "Msg 5061...ALTER DATA BASE failed because a lock could not be placed on database ..."It completes successfully when using a sysadmin login According to stackoverflow.com the solution is to kill the active/sleeping connections to the database, before ALTER-ing it, which works fine, but the question is....

Questions: Why the "ALTER DATABASE..." statement works under the sysadmin login, but not under a dbcreator one?Does this mean the sysadmin login kills the connections to the target database in the background?Is it possible to grant additional privileges to the restricted login, so the "ALTER DATABASE..." statement won't need preventive killing of the connections?

View 5 Replies View Related

Database Mirroring Hangs On ALTER DATABASE SET PARTNER

Jun 26, 2005

Hi,

View 6 Replies View Related

Question About Log File Size When Alter Huge Table

Oct 31, 2005

I have the next question, and i would like to hear what do you thinkabout, and if is there a better solution for "my problem"here is the question, I have a huge table with 60GB of data (imagefiles). The problem happen always when i try to ALTER the structure ofthe table. For example I change a field char(3) to char(4)...thesqlserver then performs the "alter table" command...that must besomething similar than "insert into the new table + drop the actualtable" and for that I need about 60GB o space for my LOG file, andtakes hours to complete the operation.Is this the only way to alter a single field in my table??I would like to heard you opinions...Thanks..ALberto

View 2 Replies View Related

How To Remove Secondary Data File????

Jan 16, 2003

I have a SQL Server 2000 database with a primary data file (MDF) and a secondary data file (NDF). I would like to remove the secondary file and only have the MDF. Is this possible?

Thanks, Dave

View 3 Replies View Related

Shrinkfile/remove File On Active DB

Mar 14, 2003

Can I execute these commands while the database is in
multi_user mode and is being actively accessed (via a
ColdFusion web app)?

dbcc shrinkfile (Web_data2,EMPTYFILE)
GO
alter database Web remove file Web_data2
GO
.

View 1 Replies View Related

SQL 2012 :: Remove TempDB NDF File

Jul 8, 2014

I have added ndf to tempdb for checking performance improvement.... Now I want to remove the ndf file... I am using below command...

USE tempdb
GO
DBCC SHRINKFILE (3, TRUNCATEONLY);
GO
use master
go
ALTER DATABASE TEMPDB Remove FILE tempdev1

Results:
DbIdFileIdCurrentSizeMinimumSizeUsedPagesEstimatedPages
23766476643232

Error:-
(1 row(s) affected)
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Msg 5042, Level 16, State 1, Line 1

The file 'tempdev1' cannot be removed because it is not empty.

Note:
=>I restarted SQLServer from SSMS and then ran same commands mentioned above ,......and getting same error...
=> I executed above commands and restarted services...no change...

How to remove / drop ndf file...

View 7 Replies View Related

Remove First Line Within A Flat File

Feb 1, 2008

Hello,
Does anyone know of a way to remove the first line of characters from a flat file?

Thank you for your help!

cdun2

View 1 Replies View Related

DB Engine :: Cannot Remove One Last Data File From TempDB

May 19, 2015

In tweaking performance of tempdb by adding add'l data files I want to reset back to defaults and remove all add'l files I've created.  I was not able to do it for most as they were in use, but by starting the server in single-user mode with all other sql services shut off, and using sqlcmd I was able to use the ALTER DATABASE tempdb REMOVE FILE <tempdev#> to remove the files... except for one.

I have also tried using the command:

ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev#, FILENAME = '<new location');

Restarted SQL server, and tried the ALTER DATABASE ... REMOVE FILE again but am always denied with the message that the file can't be removed b/c it's still in use.

I also tried to shrink it with EMPTYFILE but that also fails with the message that a page is a work table page and can't be removed.

I really need to get tempdb back to just one data file but am unable to find a way to remove this last data file.

View 2 Replies View Related

DB Engine :: How To Remove Log File Older Than X Days

Apr 20, 2015

Log file rotation and cleanup script and how to remove the log file older then x days.

View 7 Replies View Related

Need To Remove Certain Rows From The Flat File Before Transformation

Jun 4, 2007

hi

I have a flat file as below

Date 20070606

Empid Salary X1 x2 x3 x4 x5

100 10000 .............................





where 10000 is the salary got on date 20070606 by empid 100

.x1,x2,x3...are the remaining columns in the file.I need to extract the date and also continue reading the remaining data.How can i do this???



Any help?



thanks

ami

View 1 Replies View Related

The Database File May Be Corrupted. Run The Repair Utility To Check The Database File. [ Database Name = SDMMC Storage Cardwinp

Oct 9, 2007

yes,I have an error, like 'The database file may be corrupted. Run the repair utility to check the database file. [ Database name = SDMMC Storage Cardwinpos_2005WINPOS2005.sdf ]' .I develope a program for Pocket Pcs and this program's database sometimes corrupt.what can i do?please help me

View 4 Replies View Related

Create Database And Alter Database In One SQL Script

Aug 25, 2000

I am using SQL 6.5. Can I create a database and Alter the same
database in one SQL Script?
Thanks in advance.

View 1 Replies View Related

Need To Remove Jounal File After : Transfer/apply To Secondary Db

Jul 26, 2004

We are using log shipping and we would like to remove all transfered and applied journal (in the primary box).
We have the intentionto use a trigger like this :


CREATE TRIGGER del_log
ON log_shipping_plan_history
AFTER INSERT
as
declare
@lastfile nvarchar(256)
SELECT @lastfile=i.last_file
FROM log_shipping_plan_history e INNER JOIN inserted i ON e.sequence_id = i.sequence_id
where i.activity=1
begin
if IF (@lastfile <> NULL)
...
... remove file (using xp_cmd for example...)
...
end

but the problem is that we have only the last file transfered and applied that will be removed
(some time, more that 1 file are applied in one shot ...
see num_files column in log_shipping_plan_history).

Any solution to remove all the files generated before the last one given by the query ?
Any other solutions (sql wizard gives the possiblity to to remove file after a laps of time 1hour, 1day...).

I am looking for the table that contains all the journal files (that we can see when we try to retore a db) ?

Thanks

View 1 Replies View Related

Integration Services :: Remove Certain Line Feeds In CSV File

Jun 23, 2015

I have a CSV file that I am importing via SSIS into a SQL table.On the Flat File connector, I have specified Line Feed as the row delimiter.The data flow is failing due to some of the rows having line feeds before the end of the row.Is there a way to get rid of some line feeds but not others, so that I can run the data flow successfully.

View 6 Replies View Related

Alter Table Alter Column In MSACCESS. How Can I Do It For A Decimal Field?

Jul 23, 2005

Hi people,I?m trying to alter a integer field to a decimal(12,4) field in MSACCESS 2K.Example:table : item_nota_fiscal_forn_setor_publicofield : qtd_mercadoria integer NOT NULLALTER TABLE item_nota_fiscal_forn_setor_publicoALTER COLUMN qtd_mercadoria decimal(12,4) NOT NULLBut, It doesn't work. A sintax error rises.I need to change that field in a Visual Basic aplication, dinamically.How can I do it? How can I create a decimal(12,4) field via script in MSACCESS?Thanks,Euler Almeida--Message posted via http://www.sqlmonster.com

View 1 Replies View Related

Alter Database

Jan 23, 2001

I am trying to move one of my database log to different location but I am geeting an error when I try to do this.

I am moving Registration DB log file from 'c:mssql7
egistrstion_log.ldf'
to 'e:sql
egistration_log.ldf'

Here the syntax I am using to do this:

alter database registration modify file (name='registration_log',filename= 'e:sql
egistration_log.ldf')

But I get the following error:
Server: Msg 5037, Level 16, State 1, Line 2
MODIFY FILE failed. Do not specify physical name.


Thank You,
John

View 1 Replies View Related

Alter Database

Jul 31, 2006

Hi all this is my first of most likely many posts.
I am writting a stored proc that will be used on many diffrent named databases and i am setting the database name with a variable. I would like to use this variable in the following situation any clues on this would be greatly appreciated.

DECLARE @DBName varchar(50)
SET @DBName='Database'
alter database @DBName set recovery full

regards
Phil

View 4 Replies View Related

ALTER DATABASE

Apr 25, 2008



Hey,

I am trying to give a user permission to change the name of a database.

They are a member of the server role 'secuirtyadmin'
They are a member of the database role 'db_owner'
They have been granted ALTER permission on the database.

But every time I try and run the command

ALTER DATABASE <dbname> MODIFY NAME = <newdbname>

I get an error saying the database doesn't exist or you don't have permissions.

What am I missing?

View 7 Replies View Related

Remove Invalid Character From TXT File Value In Copy Column Transformation....!

Dec 6, 2007

In DTS/SSIS packages, How do to data validation or check for special characters and remove them at Copy column level.

thanks,

View 3 Replies View Related

Alter Database Failed

Mar 13, 2003

Hello,

I have Test database with Log file property Automatically grow the file, option Unrestricted file growth, I wanted to alter it with Restrict file growth upto 200 MB. I'm getting an error that you cannot modify as file doesnot exist
But the file does exist. I cannot figure out what is giving the problem.
below is the sql statements
select name from sysfiles
go

Test_Data
Test_Log

USE master
go
ALTER DATABASE Test MODIFY FILE
( NAME='Test_Log',
MAXSIZE=200MB )
go

ERROR
Server: Msg 5041, Level 16, State 1, Line 1
MODIFY FILE failed. File 'Test_Log' does not exist.

Any help is appreciated.

Thanks
Sejal

View 3 Replies View Related

Alter Database While Suspect

Jan 22, 2004

Hi

I got the following error
Error: 823, Severity: 24, State: 4
I/O error 33(The process cannot access the file because another process has locked a portion of the file.) detected during write at offset
0x0000000a796000 in file xxxxxxxxx.ndf'.

and the respective database could not be brought online - this was just due to a problem with a .ndf file containing only indexes...is there any way to connect to/alter a database while it is in this transitional state? (it would be no loss if i could just remove the file & its filegroup)

(i tried starting with -f -c, but no go)

thanks in advance
des

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved