Cannot Delete A File
Feb 22, 2001Hi,
I have by mistake created a file by name abc.ndf on Primary filegroup on a database.
Now when I delete it it says can't delete because file is not empty.
I want to get rid of this file.
Any suggestion.
Hi,
I have by mistake created a file by name abc.ndf on Primary filegroup on a database.
Now when I delete it it says can't delete because file is not empty.
I want to get rid of this file.
Any suggestion.
In a server we had File Growth,And then We had to Add New Hard Drive And New File On It.And Now We have New server with a Huge Hard Drive.But all files remaind.Can I Reduce This files to One data file or not ?
View 3 Replies View RelatedI have created a File System task which is contained in a Foreach Loop Container. I have .bak files that are populating a directory from a maintenance backup plan.
There is a point where I need to delete the .bak file's after I've zipped them all up.
How do I set the SourceVariable to read through the directory and pick up just the .bak file's in the directory to delete.
Our server is getting pretty full, the data has already been backed up, but it did not create additional room on the server. Can I delete the log file as long as I have backed up the items I need? We are running Microsoft SQL 2000.
Thanks for the help!
Can anyone point me to an example or tell me. How to run a job that delete's a file from a directory on a server? A have a ftp process that send's a larger flat file to my sql server every hour, which after about 4hr will full my server. I need to delete this file from its d drive location.
Thanks Reggie
Hello
We have a SQL Server 2000 database with 2 transaction log files.
The 2nd file was created when we were running out of disk space and the person creating it was not familiar with the dbcc shrink command.
I now want to get rid of the 2nd log file. I ran the following steps with no success:
DBCC SHRINKFILE ('Log_file', EMPTYFILE )
--Message: Cannot shrink log file 3 (log_file) because all logical log files are in use.
ALTER DATABASE db1 REMOVE FILE 'Log_file'
--Message: The file 'Log_file' cannot be removed because it is not empty.
There are no users or open transactions in the database. I have also tried sp_detach_db and sp_attach_single_file_db but that does not work either as the database attaches both the transaction logs back.
Please advise.
Thanks
Nina
Hi,
I have a database which size is 64Go, and i backup it everyday with 1 day of retention.
But the maintenance plan don't delete the file older than 1 day.
This works fine for the other db.
Do you know what is the pb ?
regards.
how to delete a very huge log file, to free up some harddisk space
View 3 Replies View RelatedI have a table in my database on SQL Server which holds a file namethat refers to a file that is stored on the server. I would like tocreate a trigger to delete this file from the server if the row in thetable is deleted. I have been trying to use this command in a trigger(<filename> is the name and path of the file):xp_cmdshell "delete <filename>"If some one could please help I would appreciate it very much. Iwould love a code sample if you have one. Thank you so very much.From,Ryan
View 2 Replies View Relatedhi...
how to delete text files from c drive (ex: c:sale300407.txt) using ms sql express edition 2005 ?
plz help me...
I've inherited a procedure that performs a few transforms and writes to flat files in a working directory using a connection in connection manager.
After the manipulation, the system cleans up by deleting the working files. Works fine in development, but from the command line gives:
The process cannot access the file <filename> because it is being used by another process.".
I suspect this is because connection manager still has the file open.
Any ideas?
Thanks
Guy
I want delete a file from the NTFS file system (assuming the right permissions are given) using the script or any other way. But I need to schedule a job which reads some table in SQL server and determines which files needs to be deleted and then I need to phyiscally delete these files.
Please can anybody help me putting me in the right direction
Thanks in advance.
Hi,
I've created a few audit trace sessions and each of them is producing files.
The procedure I used is listed below:
IF EXISTS (SELECT 1 FROM sysobjects WHERE [name] = 'sp_Turn_Audit_On' AND type = 'P')
DROP PROC sp_Turn_Audit_On
GO
CREATE proc sp_Turn_Audit_On
as
/************************************************** **/
/* Created by: SQL Profiler */
/* Date: 11/15/2006 05:16:40 PM */
/************************************************** **/
-- Create a Queue
declare @rc int
declare @TraceID int
declare @maxfilesize bigint
set @maxfilesize = 1024
exec @rc = sp_trace_create @TraceID output, 2, N'E:Program FilesMicrosoft SQL ServerMSSQLTraceAudit_Info.trc', @maxfilesize, NULL
if (@rc != 0) goto error
-- Client side File and Table cannot be scripted
-- Set the events
declare @on bit
set @on = 1
begin
exec sp_trace_setevent @TraceID, 14, 1, @on
exec sp_trace_setevent @TraceID, 14, 6, @on
exec sp_trace_setevent @TraceID, 14, 9, @on
exec sp_trace_setevent @TraceID, 14, 10, @on
exec sp_trace_setevent @TraceID, 14, 11, @on
exec sp_trace_setevent @TraceID, 14, 12, @on
exec sp_trace_setevent @TraceID, 14, 13, @on
exec sp_trace_setevent @TraceID, 14, 14, @on
exec sp_trace_setevent @TraceID, 14, 16, @on
exec sp_trace_setevent @TraceID, 14, 17, @on
exec sp_trace_setevent @TraceID, 14, 18, @on
exec sp_trace_setevent @TraceID, 15, 1, @on
exec sp_trace_setevent @TraceID, 15, 6, @on
exec sp_trace_setevent @TraceID, 15, 9, @on
exec sp_trace_setevent @TraceID, 15, 10, @on
exec sp_trace_setevent @TraceID, 15, 11, @on
exec sp_trace_setevent @TraceID, 15, 12, @on
exec sp_trace_setevent @TraceID, 15, 13, @on
exec sp_trace_setevent @TraceID, 15, 14, @on
exec sp_trace_setevent @TraceID, 15, 16, @on
exec sp_trace_setevent @TraceID, 15, 17, @on
exec sp_trace_setevent @TraceID, 15, 18, @on
exec sp_trace_setevent @TraceID, 20, 1, @on
exec sp_trace_setevent @TraceID, 20, 6, @on
exec sp_trace_setevent @TraceID, 20, 9, @on
exec sp_trace_setevent @TraceID, 20, 10, @on
exec sp_trace_setevent @TraceID, 20, 11, @on
exec sp_trace_setevent @TraceID, 20, 12, @on
exec sp_trace_setevent @TraceID, 20, 13, @on
exec sp_trace_setevent @TraceID, 20, 14, @on
exec sp_trace_setevent @TraceID, 20, 16, @on
exec sp_trace_setevent @TraceID, 20, 17, @on
exec sp_trace_setevent @TraceID, 20, 18, @on
exec sp_trace_setevent @TraceID, 37, 1, @on
exec sp_trace_setevent @TraceID, 37, 6, @on
exec sp_trace_setevent @TraceID, 37, 9, @on
exec sp_trace_setevent @TraceID, 37, 10, @on
exec sp_trace_setevent @TraceID, 37, 11, @on
exec sp_trace_setevent @TraceID, 37, 12, @on
exec sp_trace_setevent @TraceID, 37, 13, @on
exec sp_trace_setevent @TraceID, 37, 14, @on
exec sp_trace_setevent @TraceID, 37, 16, @on
exec sp_trace_setevent @TraceID, 37, 17, @on
exec sp_trace_setevent @TraceID, 37, 18, @on
exec sp_trace_setevent @TraceID, 46, 1, @on
exec sp_trace_setevent @TraceID, 46, 6, @on
exec sp_trace_setevent @TraceID, 46, 9, @on
exec sp_trace_setevent @TraceID, 46, 10, @on
exec sp_trace_setevent @TraceID, 46, 11, @on
exec sp_trace_setevent @TraceID, 46, 12, @on
exec sp_trace_setevent @TraceID, 46, 13, @on
exec sp_trace_setevent @TraceID, 46, 14, @on
exec sp_trace_setevent @TraceID, 46, 16, @on
exec sp_trace_setevent @TraceID, 46, 17, @on
exec sp_trace_setevent @TraceID, 46, 18, @on
exec sp_trace_setevent @TraceID, 47, 1, @on
exec sp_trace_setevent @TraceID, 47, 6, @on
exec sp_trace_setevent @TraceID, 47, 9, @on
exec sp_trace_setevent @TraceID, 47, 10, @on
exec sp_trace_setevent @TraceID, 47, 11, @on
exec sp_trace_setevent @TraceID, 47, 12, @on
exec sp_trace_setevent @TraceID, 47, 13, @on
exec sp_trace_setevent @TraceID, 47, 14, @on
exec sp_trace_setevent @TraceID, 47, 16, @on
exec sp_trace_setevent @TraceID, 47, 17, @on
exec sp_trace_setevent @TraceID, 47, 18, @on
exec sp_trace_setevent @TraceID, 104, 1, @on
exec sp_trace_setevent @TraceID, 104, 6, @on
exec sp_trace_setevent @TraceID, 104, 9, @on
exec sp_trace_setevent @TraceID, 104, 10, @on
exec sp_trace_setevent @TraceID, 104, 11, @on
exec sp_trace_setevent @TraceID, 104, 12, @on
exec sp_trace_setevent @TraceID, 104, 13, @on
exec sp_trace_setevent @TraceID, 104, 14, @on
exec sp_trace_setevent @TraceID, 104, 16, @on
exec sp_trace_setevent @TraceID, 104, 17, @on
exec sp_trace_setevent @TraceID, 104, 18, @on
exec sp_trace_setevent @TraceID, 107, 1, @on
exec sp_trace_setevent @TraceID, 107, 6, @on
exec sp_trace_setevent @TraceID, 107, 9, @on
exec sp_trace_setevent @TraceID, 107, 10, @on
exec sp_trace_setevent @TraceID, 107, 11, @on
exec sp_trace_setevent @TraceID, 107, 12, @on
exec sp_trace_setevent @TraceID, 107, 13, @on
exec sp_trace_setevent @TraceID, 107, 14, @on
exec sp_trace_setevent @TraceID, 107, 16, @on
exec sp_trace_setevent @TraceID, 107, 17, @on
exec sp_trace_setevent @TraceID, 107, 18, @on
exec sp_trace_setevent @TraceID, 109, 1, @on
exec sp_trace_setevent @TraceID, 109, 6, @on
exec sp_trace_setevent @TraceID, 109, 9, @on
exec sp_trace_setevent @TraceID, 109, 10, @on
exec sp_trace_setevent @TraceID, 109, 11, @on
exec sp_trace_setevent @TraceID, 109, 12, @on
exec sp_trace_setevent @TraceID, 109, 13, @on
exec sp_trace_setevent @TraceID, 109, 14, @on
exec sp_trace_setevent @TraceID, 109, 16, @on
exec sp_trace_setevent @TraceID, 109, 17, @on
exec sp_trace_setevent @TraceID, 109, 18, @on
exec sp_trace_setevent @TraceID, 110, 1, @on
exec sp_trace_setevent @TraceID, 110, 6, @on
exec sp_trace_setevent @TraceID, 110, 9, @on
exec sp_trace_setevent @TraceID, 110, 10, @on
exec sp_trace_setevent @TraceID, 110, 11, @on
exec sp_trace_setevent @TraceID, 110, 12, @on
exec sp_trace_setevent @TraceID, 110, 13, @on
exec sp_trace_setevent @TraceID, 110, 14, @on
exec sp_trace_setevent @TraceID, 110, 16, @on
exec sp_trace_setevent @TraceID, 110, 17, @on
exec sp_trace_setevent @TraceID, 110, 18, @on
exec sp_trace_setevent @TraceID, 115, 1, @on
exec sp_trace_setevent @TraceID, 115, 6, @on
exec sp_trace_setevent @TraceID, 115, 9, @on
exec sp_trace_setevent @TraceID, 115, 10, @on
exec sp_trace_setevent @TraceID, 115, 11, @on
exec sp_trace_setevent @TraceID, 115, 12, @on
exec sp_trace_setevent @TraceID, 115, 13, @on
exec sp_trace_setevent @TraceID, 115, 14, @on
exec sp_trace_setevent @TraceID, 115, 16, @on
exec sp_trace_setevent @TraceID, 115, 17, @on
exec sp_trace_setevent @TraceID, 115, 18, @on
-- Set the Filters
declare @intfilter int
declare @bigintfilter bigint
exec sp_trace_setfilter @TraceID, 10, 0, 7, N'SQL Profiler'
-- Set the trace status to start
exec sp_trace_setstatus @TraceID, 1
-- display trace id for future references
select TraceID=@TraceID
goto noCursor
error:
select ErrorCode=@rc
noCursor:
return
end
Unfortunately, I didn't mention the @stoptime for each of the trace sessions and now I'm unable to delete the trace files. Is there any select statement that will be useful in finding the @traceid for these auditting sessions? Also, how am I able to stop the sessions without stopping the related services?
Thank you in advance.
Best regards,
Alla
I have to run a DTS package to export data into a dBase file. I first have to delete the existing data within the dbase file, but I can only get it to delete the data, not the actual rows. The file continues to grow in size. Is there a way to delete the rows from the dbase file through the DTS package?
This would help out a lot, thank you!!
I am trying to restore a DB. After Detaching the DB I wanna delete the Ldf . How to delete this physical file Using Sql Query????
Thank You in advance.
i have a text file that is like:date = OCT0606asdfsdafasdfasdgsdghasdfsdfasdgSTART-OF-DATAasdfasdfgasdfgdfgsfgsadfsdfgsaasdfgsdfgEND-OF-DATAasdfgalsdkdfklmlkmasdfgasdfgi need to clear everything from this file except the data between theSTART-OF-DATA and END-OF-DATA using a batcj file... elternitavly i amopen to suggestions of how to import using bulk insert in sql withoutchanging the file at all. data is pipe seperated but obvioulsy hasplenty of junk data in it. i have 2 similar files at about 30mb and60mb in size. thnks everyone
View 15 Replies View RelatedI have a file in my script task, which does this job.
Public Sub Main()
Dim fs As New FileStream("\abcdefgabcdergFiles2.ftp", FileMode.Create, FileAccess.Write)
Dim s As New StreamWriter(fs)
s.BaseStream.Seek(0, SeekOrigin.End)
s.WriteLine("open 112.123.123.12")
s.WriteLine("abcdef")
s.WriteLine("abcd")
s.Close()
Dts.TaskResult = Dts.Results.Success
End Sub
After this task gets completed, I want to delete this file-the file which was created just now. How to write that code to delete that file. I am not sure, if this is the right place to put this issue.
Thanks.
Hi,
I want to delete all files in a folder where creation date is an year older. I created a For Each Loop container to go over the whole folder and then execute the following Script Task
Dim FileArchive As Int16
Dim dteArchive As Date
Dim FilePath As String
FileArchive = CType(Dts.Variables("FileArchive").Value, Int16) ' One Year FileArchive = 365
dteArchive = DateAdd("d", -FileArchive, Now.Date)
FilePath = Dts.Variables("FilePath").Value.ToString
If File.GetCreationTime(FilePath) <= dteArchive Then
Try
File.Delete(FilePath)
Catch ex As Exception
'Do Nothing
End Try
End If
Dts.TaskResult = Dts.Results.Success
Is there a better approach to this? As most of the time job may have to delete 10 or 15 files but he has to read each file and then check the date if it matches the criteria and it delete.
I have to load and unload many datatabases for testing. So I wanted to quickly remove a database, its devices and respective dat files
all at once.
Is there a way of completely dropping a database so that all trace of it is quickly gone?
How do I delete records in the destination file in SSIS using BI Development Studio?
View 1 Replies View RelatedHow do I delete records in the destination file in SSIS using BI Development
Studio? Thanks.
Is there any idea regarding query to delete any operating system file from sql server.
Basically i want to delete temp files in tmp folder of Windows.
-----
sim
I encounter one weird problem, I have a database with around 7 GB ...when I delete a bunch of data from it, it suppose to reduce thedatabase file size, but weirdly, the file size increase to 8 GB.Wondering why. Is it suppose to be like that?Is it the architecture is designed to work like that?Is there any way for me to reduce the database file size?Thanks.Peter CCH
View 2 Replies View RelatedI finally put together a SSIS package that takes a Text File and successfully imports its data into the right table. My question is, where in the package's properties can I find the option to Delete all rows from Destination Columns prior to Importing. I have looked everywhere in the Package Explorer for this setting. Thanx in advance.
View 3 Replies View RelatedHi,I have some database files (.MDF, .LDF,...) on the server. When I tryto delete them, the warning "Cannot delete file: There has been asharing violation. The source or destination file may be in use."appears.Since I am new to the environment I don't know where the files comefrom and where they might be used.Can anybody tell me what to do to delete those files?Thank you.
View 36 Replies View RelatedThis delete's the directory content as well as sub directory content! Is their a way i can just set it to delete the files in the said directory and not sub directories?
View 11 Replies View RelatedI know there is a command xp_delete_file for SQL 2005 but if I want to delete a file from a 2000 database is there a command to do the same.
View 4 Replies View RelatedI need to delete the second row in an excel file in my SSIS package. Is that possible to do?
View 2 Replies View RelatedI just wanted to delete a record from a filetable by "delete from dbo.DocumentStore where stream_id = 'A322276D-AE65-E511-8266-005056C00008'".
Then i received error 1934:
Meldung 1934, Ebene 16, Status 1, Zeile 578
Fehler bei DELETE, da die folgenden SET-Optionen falsche Einstellungen aufweisen: 'ANSI_PADDING'. Überprüfen Sie, ob die SET-Optionen für die Verwendung mit indizierte Sichten und/oder Indizes für berechnete Spalten und/oder gefilterte Indizes und/oder Abfragebenachrichtigungen
und/oder XML-Datentypmethoden und/oder Vorgänge für räumliche Indizes richtig sind.
Something that i made a mistake with the SET-option for 'ANSI_PADDING' with indexted views and/or calculated rows and/or filtered indeces ...
Hello everybody
I have one question about deleting blank row on flat file destination from conditional split.
I create an SSIS package to filter data from Flat file source.
On flat file source, it is Ragged right format and header row delimeter in {CR}{LF}
the coulums are devided manulaay using markers.
I use only 2 columns divided and send the source into conditional split task and the conditions are given to filter data,
when the output from conditional split is placed on flat file destination, i notice blank rows on the output. I want to delete the blank rows so the result data can be displayed continuously in rows.
anybody has any idea for this? I know the script task will work but hope to avoid to use script task.
Thank you in advance for all the help.
Hi,
Question pls. I have an MS SQL local package where it exports data from SQL table to Excel file. My question is, how can erase all the records in my excel file before i export the new data from SQL table?
What i want is to delete the rows in the destination file before inserting new records.
Thanks a lot.
I am struggling figuring out the token from a CMDEXEC job (as opposed to TSQL Job). It is not an option to execute the command by enabling the executing CMDs via TSQL, which is why I am using the agent. I have seen the Microsoft Site on tokens but all examples seem to be oriented to TSQL Job Type.
I am trying to delete a particular trace file and at same time keeping the SQL Directory dynamic.Taking it a step further is adding in "deleting if file exist".
del $(ESCAPE_SQUOTE(SQLDIR)) + "LogTestTrace.trc"
Currently we has a database of size about 300G. Because our backup system failed some time past we were left with a transaction log file which grew to about 160G. However our backups are working again and everything is working fine. My understanding is that now the transaction log file is practically empty but the capacity remains at 160G.
When you delete records the deleted transactions are going to get logged to the transaction file. My understanding is when a backup is done these transactions get discarded out of the transaction file.
could I make use of this relatively large transaction file and start deleting transactions without out actually adding to the transaction file size.
The plan is to delete records from logging tables that are not referenced to by any other table without this increasing the transaction log file.For example over a period of a few weeks we can delete a chunk of records from a table. Then after it has completed a backup we can delete another chunk of records out of this table until we have got the table down to the records that we now need.Will this work?