Deleting A File Ffrom The DB

Apr 4, 2006

Hi All

Was getting this error

Server: Msg 1101, Level 17, State 10, Line 1
Could not allocate new page for database 'TEMPDB'. There are no more pages available in filegroup DEFAULT. Space can be created by dropping objects, adding additional files, or allowing file growth.

So went to EM & added another file (Additional file in some other drive ) to the Tempdb , now I want to delete this file ???

What are the steps ... I cant re-start the SQL Server


Please help .

View 2 Replies


ADVERTISEMENT

Deleting A File From File System - Syntax Error

Jun 29, 2015

Ok so I have some dynamic sql to delete a file that is created via sql earlier on. It is to provision a copy of a database to an instance on link server. Everything works great and the files used to delete. Now, with no code changes it is throwing a syntax error. I do a print of what the dynamic sql is creating before executing and then I copy / paste what was generated into command prompt and guess what!! The file deletes.

Here is the result on screen:

@DeleteBackupFileStatement: DEL adas16.clients.advance.localwip$AvionteAP_Template_893.bak /Q
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ''.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ''.

Here is the code that creates the statement:

SET @DeleteBackupFileStatement = NULL
BEGIN
SET @DeleteBackupFileStatement = 'DEL ' + LTRIM(RTRIM(@BackupFile)) + ' /Q'
END
PRINT '@DeleteBackupFileStatement: ' + cast(@DeleteBackupFileStatement as varchar(400))
BEGIN
EXEC adasdb.master.sys.Sp_executesql
@DeleteBackupFileStatement
END
END

The value of @BackupFile is simply the path of the file with the file name, everything in the prepared statement with the exception of DEL and the switch at the end.

View 9 Replies View Related

Deleting A Log File

Mar 5, 2001

How can you delete a log file.
Say I have backed up a transaction log at some drive say G:.
Now I want to delete this log file and want to define it in a job.
What is the syntax -
delete G:Test_log.bak ????
What is a proper syntax??
Thanks!

View 1 Replies View Related

Error While Deleting .mdf File

Apr 15, 2008

can some one please help me to delete a File with extension .mdf, as its continously giving error that file can't be deleted its being used by any other program or user.

Rahul Arora
07 Batch
NCCE Israna,


######################
IMPOSSIBLE = I+M+POSSIBLE

View 8 Replies View Related

Deleting Transaction Log File

Apr 16, 2008

I am trying to remove the transaction log file since I have created another one on a seperate drive by it wont let me do it . I get this error "cant delete the primary data or log file"
Now microsoft site clearly state steps for deleting the transaction log file , by first emptying it and then deleting it BUT IT DOESNT WORK.
I have even tried detaching the database and then removing the transaction log file and then attaching the database again BUT it attaches the transaction file back again GRRRRRR

then on top of this MS SQL studio does not allow to put PRIMARY or anyother value to the Filegroup for tansaction log files so how on earth can a transaction file be "primary" as the error is stating ??????

can anyone tell me how to get rid of a transaction log file that was created with the database ?

View 4 Replies View Related

Problems Deleting SQL.LOG File

Oct 13, 2006

Hi,

I can not delete this file from C/Windows/Temp directory, all other files form that foder I can delete. The error message I get is that something else is using this file. The thing is I cant find what is using it, even though I uninstaled SQL Server 2005 completely. I have tried lots of things, nothing helps. At the end I entered windows in SAFE MODE, went to Computer Management and disabled almost every service I can, that might be using it, and still cant get rid of this SQL.LOG which is 26GB now. The only thing I could do is to compress the file and now it is 6.5GB.

Txs for the help..

View 1 Replies View Related

Deleting 1st And Last Line From A Text File.

Jun 22, 2002

Hi ALL,
I need to delete 1st and last lines of text from a text file in an automated process,and save the file with the same name or a different name at the same location. How is that possible?Any help is greatly appreciated.
Thanks!!
Sai.

View 1 Replies View Related

DB Engine :: Deleting A Log File Permanently?

Jul 6, 2015

In SQL 2012 I'm trying to delete a log file (both physically and logically). There are two log files and one of them is unnecessary. When I click 'remove' in SSMS it will delete the log file, but then when I go back under database properties it's still showing up even though the file has been physically removed from the OS. I'm wondering what steps I can take to get rid of the file permanently?

View 12 Replies View Related

Deleting Data Bloats Log File

Aug 22, 2007

When I delete substantial amounts of data using the SQL DELETE command, the database size apparently remains the same (702 mb) and the log file goes from about 17 mb to over 1 gig. I was expecting for the overall size to decrease drastically, but got just the opposite.

Is this typical? Can I do something to slim it down? As I am just trying to decrease the overall size to make it easier to work with when creating my application in VB, I am not worried about restoring the db (I have secure copies).

View 15 Replies View Related

Deleting Lines From A Text File

May 29, 2007

I have a flat file that look like this



############################################################
# Market Issue Lookup
# Applies to: Muni,Pfd,Govt,Corp
###########################################################
LU_MARKET_ISSUE| |AUSTRALIAN|Corp|
LU_MARKET_ISSUE| |BULLDOG|Corp|
LU_MARKET_ISSUE| |CANADIAN|Corp|
LU_MARKET_ISSUE| |WARRANTS|Muni|
LU_MARKET_ISSUE| |YANKEE|Corp|



############################################################
# Maturity Type Lookup





and i want it to look like this



LU_MARKET_ISSUE| |AUSTRALIAN|Corp|
LU_MARKET_ISSUE| |BULLDOG|Corp|
LU_MARKET_ISSUE| |CANADIAN|Corp|
LU_MARKET_ISSUE| |WARRANTS|Muni|
LU_MARKET_ISSUE| |YANKEE|Corp|



Basically remove any line that start with a "#" or any blank lines..



I am assuming you can do this only using a script component and not directly through ssis..but i am not too familiar with scripting...so some code would be helpful



Thanks for any help in advance.



smathew

View 5 Replies View Related

Updating Mdf File Without Deleting Member Roster

Apr 11, 2007

I use discountasp.net. I've added some new tables that I'd like to place on my website. My problem is that if I reattach my mdf file to my server, my member roster gets deleted. So my question is how can I update the mdf file without losing member information?
 
Thanks,JW

View 1 Replies View Related

Replication Does Not Work After Deleting The LDF File Manually.

Feb 6, 2004

I have maually deleted the Database.LDF file by stopping the SQL Server. When i start the SQL Server, merge replication which was configured for the database does not work. How do i fix this problem.

Thanks in advance.

Regards,

Venu.

View 1 Replies View Related

Deleting Expired Backupsets From Single .BAK File

May 28, 2008

Hi,

I'm new to SQL Server 2005 (up until now I've been an Oracle DBA exclusively) and have been tasked with backing up all (6) of our SQL Server 2005 databases on a regular basis. To accomplish this, I've created individual SQL Server jobs for each database I wish to backup. Each of these jobs executes a T-SQL script like this:


BACKUP DATABASE [MYDATA] TO DISK = N'\networksharemydata.bak' WITH RETAINDAYS = 4,
NOFORMAT,
NOINIT,
NAME = N'MyData-FullBackup',
SKIP,
NOREWIND,
NOUNLOAD,
STATS = 10
GO


My goal in specifying 'RETAINDAYS = 4' was so that there would always be 4 days worth of "backupsets" (forgive my Oracle-ese) kept in mydata.bak. But when I look at the amount of backupsets kept in mydata.bak I noticed that all of them were being kept and none were being deleted.


I researched this problem a little bit and thought I had discovered a solution by specifying 'INIT' instead of 'NOINIT' and 'NOSKIP' instead of 'SKIP', but this deletes the entire contents of mydata.bak only-if all of the backupsets contained in it are past their expiration date. I was hoping it would just delete the expired backupsets and keep the non-expired ones, but this isn't the case.


Does anyone know the simplest way - with T-SQL commands - to accmplish the task of backing up a database to 1 individual .bak file and also only retain x amount of "backupsets" within it? Any help would be greatly appreciated, and the more detailed the better. Thanks.


- Gary

View 18 Replies View Related

Deleting Expired Backupsets From Single .BAK File

May 27, 2008



Hi,


I'm new to SQL Server 2005 (up until now I've been an Oracle DBA exclusively) and have been tasked with backing up all (6) of our SQL Server 2005 databases on a regular basis. To accomplish this, I've created individual SQL Server jobs for each database I wish to backup. Each of these jobs executes a T-SQL script like this:



BACKUP DATABASE [MYDATA] TO DISK = N'\networksharemydata.bak' WITH RETAINDAYS = 4,
NOFORMAT,
NOINIT,
NAME = N'MyData-FullBackup',
SKIP,
NOREWIND,
NOUNLOAD,
STATS = 10
GO

My goal in specifying 'RETAINDAYS = 4' was so that there would always be 4 days worth of "backupsets" (forgive my Oracle-ese) kept in mydata.bak. But when I look at the amount of backupsets kept in mydata.bak I noticed that all of them were being kept and none were being deleted.

I researched this problem a little bit and thought I had discovered a solution by specifying 'INIT' instead of 'NOINIT' and 'NOSKIP' instead of 'SKIP', but this deletes the entire contents of mydata.bak only-if all of the backupsets contained in it are past their expiration date. I was hoping it would just delete the expired backupsets and keep the non-expired ones, but this isn't the case.

Does anyone know the simplest way - with T-SQL commands - to accmplish the task of backing up a database to 1 individual .bak file and also only retain x amount of "backupsets" within it? Any help would be greatly appreciated, and the more detailed the better. Thanks.

- Gary

View 2 Replies View Related

Integration Services :: Deleting Column From CSV File Using SSIS

Aug 18, 2015

How can we delete the column from SSIS file using ssis?

View 3 Replies View Related

Deleting The Master Table Withour Deleting The Child Tables

Aug 9, 2007

Hi
i have to delete the master table data without deleting the child table records,is there any solution for this,  parent table has relation with the child table.
regards
vinod.t.v

View 9 Replies View Related

SQL 2005 Maintenance Cleanup Task Is Not Deleting Files On Remote File Share

Jan 16, 2008

I have the following issue with Maintenance plan backups that work for BAK DIF and TRN to a remote server share.
When I try and remove the old files with a clean up task I get an error and the files don't get deleted.


The version is as follows
Microsoft SQL Server 2005 - 9.00.3054.00 (X64) Mar 23 2007 18:41:50
Copyright (c) 1988-2005 Microsoft Corporation Standard Edition (64-bit) on
Windows NT 5.2 (Build 3790: Service Pack 2)

The error result is as follows,

Failed-1073548784) Executing the query "EXECUTE master.dbo.xp_delete_file
0,N'\\EXECUTE master.dbo.xp_delete_file 0,N'\ABCD-A1\BACKUPS\ABCD_BACKUP\ABC_DAILY\ABCD',N'trn',N'2008-01-13T12:52:49'" failed with the following error: "xp_delete_file() returned error 2, 'The
system cannot find the file specified.'". Possible failure reasons: Problems
with the query, "ResultSet" property not set correctly, parameters not set
correctly, or connection not established correctly.

The maintenance plan seems to be adding extra "" though when i enter the
code directly in a query i get same error.

Query:

EXECUTE master.dbo.xp_delete_file 0,N'\ABCD-A1BACKUPSABCD_BACKUPABC_DAILYABCD',N'trn',N'2008-01-13T12:52:49'

Error:

xp_delete_file() returned error 2, 'The system cannot find the file specified.'

The servers belong to the same domain and are using the same Service account which has all the necessary rights to the share and the file directory location. The backups work but i get the error on the cleanup task.

Trying to figure out how to get the Cleanup task to delete old files. The same happens for all file extensions and I have tried other locations with simpler file paths same error.


Regards,
Scott


View 6 Replies View Related

T-SQL (SS2K8) :: Deleting Only 1 Row At A Time Instead Of Using Condition And Deleting Many Rows?

Jul 18, 2014

/****** Object: StoredProcedure [dbo].[dbo.ServiceLog] Script Date: 07/18/2014 14:30:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[ServiceLogPurge]

-- Purge records dbo.ServiceLog older than 3 months:
-- Purge records in small portions to avoid locking production tables
-- for a long time. The process takes longer, but can co-exist with
-- normal usage of the tables.

[Code] ...

*** Getting this error below when executing the code ***

Msg 102, Level 15, State 1, Procedure ServiceLogPurge, Line 45
Incorrect syntax near 'Failed:'.

View 9 Replies View Related

Need Help On Deleting

Dec 12, 2001

Please HELP!!

I need a query to DELETE the first few records in a table. For example: something like .....delete top 1000 from tablename. I figured that TOP dosent work with the DELETE. It only works with SELECT and UPDATE statments.


I cannot hardcode any values in the WHERE clause due to certain constraints in my application.

KINDLY HELP, THIS IS URGENT.

View 2 Replies View Related

Deleting Data From DB

Nov 23, 2006

I have edited the aspnet_Users_CreateUser stored procedure so that the UserId that is created when a new user is created is copied to a UserId field in another table. However, when I use the website administration tool to delete users that have been created, it gives me an error saying the delete statement conflicted with the reference constraint. I then added the following code in the aspnet_Users_DeleteUser procedure....
IF ((@TablesToDeleteFrom & 16) <> 0 AND
(EXISTS (SELECT name FROM sysobjects WHERE (name = N'vw_tt') AND (type = 'V'))))
BEGIN
DELETE FROM dbo.userclassset WHERE @UserId = UserId
SELECT @ErrorCode = @@ERROR,
@RowCount = @@ROWCOUNT
IF( @ErrorCode <> 0 )
GOTO Cleanup
IF (@RowCount <> 0)
SELECT @NumTablesDeletedFrom = @NumTablesDeletedFrom + 1    hdhd
END
This code was then added to the function at the end which deletes the data from the aspnet_Users table when everything else has been removed
(@TablesToDeleteFrom & 16) <> 0 AND
Now when I delete a user in the website admin tool, it "deletes" (with no error) the user from the list but doesnt actually physically delete it from the database.
Any ideas?
 

View 1 Replies View Related

Deleting From Sql Question.

Jan 2, 2007

I have a data source which I created a custom statement for which I need to delete from.  I created the folowing selecct statement
 SELECT [CompId], [Description], [CompName], [OS], [UserName], [DriverEntryId] FROM [SrcComputer] WHERE ([UserName] = @UserName)
I wrote the following DELETE statement
 DELETE FROM SrcComputer WHERE (CompId = @CompId)
I have tested it in SQL server management and it does what I want it to do, but I don't know how to use it in my code.  I put it inside of the DELETE tab inside of my custome statement and added a delete button inside of the gridview which utializes my data source, but it's not working.  I don't know how to set the CompId variable?  I want the statement to delete the row that the user clicks on.  Can anyone give me some advice?

View 6 Replies View Related

Deleting A Record

Oct 9, 2007

I have three tables
1. membership table(aspnet_membership table)
2. User Contacts table
3. Address table
These three table have relation ship with one another through a UserId field. 
How will you set up cascaded delete on these tables, Like if I delete a user in the membership table I want the related records in the other tables to be deleted as well. Cascaded delete is it something done through code, or is it definde when the tables are created.
Please advice. 
 

View 1 Replies View Related

Deleting Problems..

Apr 2, 2008

here i a again.. because im really having problems in deleting rows from a gridview... here is my code
SelectCommand="SELECT UserId, First, Last, Email, CreateDate, LastLoginDate, IsApproved, IsLockedOut FROM aspnet_Membership"
DeleteCommand="DELETE FROM aspnet_Membership WHERE [UserId] = @UserId"
ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" >
<DeleteParameters>
<asp:Parameter Name="UserId" Type="Int32"/>
</DeleteParameters>
 
It is working but when i click the delete button.. this appears
Must declare the scalar variable "@UserId".
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable "@UserId".Source Error:



An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:



[SqlException (0x80131904): Must declare the scalar variable "@UserId".]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +95
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +82
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +346
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3430
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +271
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +367
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +149
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +492
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) +919
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +176
System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +911
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1067
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +214
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +242
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3839
need help asap.. pls THANK YOU VERY MUCH!!!

View 1 Replies View Related

Deleting All But Top Record.

Jun 23, 2005

Hey Guys,I have Performance Monitor running and storing the network usage to my MsSQL database, and this is done a few times a minute. I have a page that then shows show much of my bandwidth is being used. As you can gather, the database quickly starts filling up with hundrreds of records so I could do with a script that delete these records. I cant simply delete all records because that would cause my webpage to fail so I need a way to delete all records apart from the latest one. Wondering if anyone would know how I could do this?

View 3 Replies View Related

Deleting From 2 Tables?

Jul 21, 2005

Hi, I am pretty new to SQL and know that I am probably going around this the wrong way.

I want to make a stored proc that deletes rows from table 1 and delete rows from table 2 where the common link is the id.

Any help would be greatly appreciated!

Many thanks

moop

View 5 Replies View Related

Deleting Old Backups

Apr 17, 2001

I am new to SQL backups but what I have done is created a script sp_BackupProcessor that is used to determine which backup type is run (Full,Differential,Transaction). I am backing up to the local drive and then our tape backup system backs up the files on our local system to tape. I only want to keep 3 days worth of backups on our local machine since the same information is stored on tape. What is the best way to handle this? Any help or ideas would be appreciated. I have included my script for reference.

Thanks,

Tim

CREATE PROCEDURE sp_BackupProcessor
@Help BIT = 0,
@Database VARCHAR(30) = NULL,
@BackupName VARCHAR(50) = NULL,
@BackupType VARCHAR(4) = NULL,
@Filename VARCHAR(255) = NULL,
@Description VARCHAR(255) = NULL
AS

Parameters:
@Database = ''master''
-- Default = ''master''
-- Specifies the database to backup.
@BackupName = ''masterLOG''
-- Default = ''masterLOG''
-- Specifies a name for the backup.
@BackupType = [''FULL'' | ''DIFF'' | ''LOG''],
-- Default = ''LOG''
-- ''FULL'' = Full database backup
-- ''DIFF'' = Differential database backup
-- ''LOG'' = Transaction Log Backup
@Filename = ''C:empmasterLOG.TRN''
-- Defualt = ''C:empmasterLOG.TRN''
-- Specifies the file to use for the backup.
-- Provide full path and filename.
@Description = ''255 cahr max''
-- Default = ''
-- Specifies a description to attach to the bakup.
Usage:
sp_BackupProcessor
@Database = ''Database'',
@BackupName = ''BackupName'',
@BackupType = [''FULL'' | ''DIFF'' | ''LOG''],
@Filename = ''FullPathLocalFile'',
@Description = ''Backup Description (255 max)''
'
RETURN 1
END

DECLARE @BackupStmt VARCHAR(500)
SELECT @BackupStmt =
CASE @BackupType
WHEN 'FULL' THEN
'BACKUP DATABASE ' + @Database + ' ' +
'TO DISK = ''' + @Filename + ''' ' +

'WITH RETAINDAYS = 2,' +
'INIT' + ', ' +
'NAME = ''' + @BackupName + ''', ' +
'NOSKIP' + ', ' +
'DESCRIPTION = ''' + @Description + ''', ' +
'NOFORMAT'
WHEN 'DIFF' THEN
'BACKUP DATABASE ' + @Database + ' ' +
'TO DISK = ''' + @Filename + ''' ' +
'WITH DIFFERENTIAL' + ', ' +
'NAME = ''' + @BackupName + ''', ' +
'NOSKIP' + ', ' +
'DESCRIPTION = ''' + @Description + ''', ' +
'NOFORMAT'
WHEN 'LOG' THEN
'BACKUP LOG ' + @Database + ' ' +
'TO DISK = ''' + @Filename + ''' ' +
'WITH NOINIT' + ', ' +
'NAME = ''' + @BackupName + ''', ' +
'NOSKIP' + ', ' +
'DESCRIPTION = ''' + @Description + ''', ' +
'NOFORMAT'
END
EXECUTE(@BackupStmt)
GO

View 1 Replies View Related

Deleting Duplicates

Apr 17, 2001

Hi,

does anyone out there know how to delete dulicate records in a table? I've looked in BOL and I can't seem to find it. Please advise.

thanks, mark

View 2 Replies View Related

Deleting Datbase

Apr 23, 2001

how do i delete an entire database when it keeps saying that the database is currently in use?

View 3 Replies View Related

Deleting Tables

Feb 21, 2001

hi,
How can I delete two tables with a WHERE condition.
That is I can't do this -What can be an alternate of this statement -

Delete from Tab1,Tab2,Tab3
where
Tab1.name = Tab2.Name and
Tab2.name = Tab3.name

TIA

View 1 Replies View Related

Deleting Tables

Aug 24, 2005

Does anyone know why it takes a long time (Approx 10 minutes) to delete a DB. I have 2 identical environments for test and prod. I can delete DBs from my test environment quickly but it takes forever to delete a DB from the production environment. I am running SQL2000 SP3a. There are about 25 DBs in the environment with their sized ranging from 100meg to 2 gig. The only differnece in the environments is all test DBs are simple recovery mode and modt prod DBs are full.

Thanks,
Ken

View 5 Replies View Related

Deleting Dups

Jul 3, 2002

I need to delete duplicate records from a SQL table where only the key field is not a duplicate. I'm not having any luck with my script. Does anyone have a scrip that might work? Thanks

View 2 Replies View Related

Deleting A Device

Dec 1, 1998

I am trying to drop a device that as no associated file in Windows NT Explorer(.dat) that shows up in my Server Manager Windows

How can I delete them?

Thanks

View 2 Replies View Related

Deleting Odd And Even Numbers

Aug 8, 2002

I have two identical databases. I need to delete the even customer numbers from the first database and the odd numbers from the other database. I know I can do this writing a delete statement for each table. However there are a total of 54 tables.

Does anyone know a faster way to write the script without writing 54 scripts?

I would appreciate your help.

As always you guys are the greatest.

Dianne

View 1 Replies View Related







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