Truncate All Tables In DB With RI Intact

Jun 22, 2004

Anyone?

I tried the following code...thought I could trap the RI Error and move on...

It raises all the way out though....

Server: Msg 4712, Level 16, State 1, Line 1
Cannot truncate table 'myTable99' because it is being referenced by a FOREIGN KEY constraint.

I thought you could trap it this way...


CREATE TABLE myTable99(Col1 int PRIMARY KEY)
GO
CREATE TABLE myTable00(Col1 int, Col2 int, PRIMARY KEY(Col1,Col2), FOREIGN KEY (Col1) REFERENCES myTable99(Col1))
GO

INSERT INTO myTable99(Col1) SELECT 1
INSERT INTO myTable00(Col1, Col2) SELECT 1,2
GO

CREATE PROC myDynamicSQL99 @sql varchar(8000) AS EXEC(@sql)
GO

DECLARE @error int, @TABLE_NAME sysname, @sql varchar(8000), @x int, @rc int
SELECT @error = 0, @x = 0

DoItAgain:

DECLARE myCursor99 CURSOR
FOR
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.Tables
WHERE TABLE_NAME LIKE 'myTable%'
ORDER BY TABLE_NAME DESC

OPEN myCursor99

FETCH NEXT FROM myCursor99 INTO @TABLE_NAME

WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @SQL = 'TRUNCATE TABLE ' + @TABLE_NAME
SELECT @SQL
EXEC @rc = myDynamicSQL99 @SQL
SELECT @Error = @@Error
SELECT 'Error Code: ' + CONVERT(varchar(15),@Error) + ' @rc: '+ CONVERT(varchar(15),@rc)
IF @Error <> 0
SELECT @x = @x + 1
FETCH NEXT FROM myCursor99 INTO @TABLE_NAME
END

CLOSE myCursor99
DEALLOCATE myCursor99

IF @x <> 0
BEGIN
SELECT @Error = 0
GOTO DoItAgain
END
GO

DROP PROC myDynamicSQL99
DROP TABLE myTable00
DROP TABLE myTable99
GO

View 14 Replies


ADVERTISEMENT

Keeping The Audit Info Intact.

Apr 10, 2008

Hi all

I have a stored procedures with few DML stmts inside.

I need to log the success/failure of each DML statment into seperate audit table as follows

Begin
DML Stmt1
Log sucess/failure (Insert stmt to audit table)
DML Stm2
Log sucess/failure (Insert stmt to audit table)
end

when any of the above DML stmt fails, the entire transaction is getting rolled back including the audit information.

How can i keep the audit info intact when the transaction is rolled back.

Thanks.

View 1 Replies View Related

Truncate Or Rebuild Tables?

Mar 8, 2001

I frequently have tables that I want to empty and refill. I thought I read somewhere that trucating was a bad idea, example:

Truncate table tblFruits

A bad idea because of something to do with the log? I'm a beginner so I don't understand transaction processing very well, or logs.

Is it better to delete the table and rebuild it in code before you add the values?

View 1 Replies View Related

How Can I Truncate Multiple Tables?

Apr 11, 2007

Hi,

I'm quite new to SQL 2000 and I've been trying to find an easy way to truncate a number of tables in a script. The table names are all prefixed with 'RESULTS_' so they are easy enough to identify. Is this fairly straightforward?

View 12 Replies View Related

Purging A Database Data While Keeping The Structure Intact

Oct 15, 2006

Is it possible to purge all records in the database while retaining the the table structures. Even better yet, could I do it on a table by table basis?   If I simply delete all the records the identities for the tables do not revert back to 1.

View 2 Replies View Related

Truncate Tables With Spaces In Their Names Using STP

Dec 16, 2005

I am attempting to how to truncate list of tables using STP. That is decalre a cursor for a list table names and then to truncate the table names one by one.

The code below shows what I want to achieve. I want to truncate all the tables with names beginning with ZZ but this is failing. I have tried using both delete and truncate.

Is it possible and what do I need to do?

-- Code

SET QUOTED_IDENTIFIER Off
GO
SET ANSI_NULLS ON
GO

create PROCEDURE dbo.Empty_ZZ
AS

DECLARE @tablename sysname
DECLARE @localname varchar(50)

DECLARE ZZtablenames_cursor CURSOR FOR
select [name]
from sysobjects
WHERE [xtype] = 'U'
and name like 'ZZ %'

OPEN ZZtablenames_cursor

FETCH NEXT FROM ZZtablenames_cursor
into @tablename
WHILE @@FETCH_STATUS = 0
BEGIN
set @localname = '[' + @tablename + ']'
TRUNCATE + @localname
FETCH NEXT FROM ZZtablenames_cursor
END

CLOSE ZZtablenames_cursor
DEALLOCATE ZZtablenames_cursor

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

View 4 Replies View Related

SQL 2012 :: Using Stored Procedure To Truncate Tables?

Jun 30, 2014

I was just looking at an SSIS package someone else set up and I went into one of the execute SQL tasks and it is calling a stored procedure to truncate a table. There are a lot of places that tables are truncated within this SSIS package. But each one the 'database', 'owner', and 'table' name are hard coded.

Like this: exec dbo.uspTruncateTable 'dbname', 'dbo', 'tblname'

Of course there are different names, just changed for an example.

Here is the code in the Stored Procedure.

CREATE procedure [dbo].[uspTruncateTable]
@nDatabase varchar(255),
@nOwner varchar(255),
@ntable varchar(255)
as
declare @sqlString nvarchar(max)
set @sqlString = 'Truncate Table ' + @nDatabase + '.' + @nOwner + '.' + @ntable
exec (@sqlString)

This just seems like an unneeded step, just code the 'truncate table dbname.dbo.tblname'.

View 5 Replies View Related

Truncate Tables Based On Foreign Key Relationships

Nov 5, 2007

Guys,

I have 600 tables in my database, out of which 40 tables are look up value tables. I want generate truncate scripts which truncates all the tables in order of Parent child relationship excluding lookup tables. Is there any way to do this apart from figuring out Parent Child relationship and then writing the truncate statements for each of the table.

For example

EmployeeDetail table references Employee table
DepartmentDetail table references Department table
Department table references Employee table

My truncate script should be

TRUNCATE TABLE DEPARTMENTDETAIL
TRUNCATE TABLE EMPLOYEEDETAIL
TRUNCATE TABLE DEPARTMENT
TRUNCATE TABLE EMPLOYEE

IS there any automated way to figure out parent and child tables and generate truncate script for the same.

Thanks

View 3 Replies View Related

Truncate Database Tables Based On Foreign Key Constraints

Nov 5, 2007

Guys,

I have 600 tables in my database, out of which 40 tables are look up value tables. I want generate truncate scripts which truncates all the tables in order of Parent child relationship excluding lookup tables. Is there any way to do this apart from figuring out Parent Child relationship and then writing the truncate statements for each of the table.

For example

EmployeeDetail table references Employee table
DepartmentDetail table references Department table
Department table references Employee table

My truncate script should be

TRUNCATE TABLE DEPARTMENTDETAIL
TRUNCATE TABLE EMPLOYEEDETAIL
TRUNCATE TABLE DEPARTMENT
TRUNCATE TABLE EMPLOYEE

Is there any automated way to figure out parent and child tables and generate truncate script for the same.

Thanks

View 1 Replies View Related

'Truncate' Command Doesn't Truncate Enough

Dec 30, 2004

With a database size of almost 2 GB, I run the 'truncate table eventlog command' which completes successfully, but the database size only decreases by about 10 MB so stays too large - indeed the number of rows in the eventlog table is minimal, but the otehr tables in this database don't show such an amount of tables large enough to cause the size issue either. What could be the reason and how can I reduce it (possibly truncating another table but then which one, how could I determine which is too large and needs truncating?).

View 3 Replies View Related

To Truncate Or Not To Truncate: That Is The Question..

Apr 17, 2008

Hi all...

Please forgive the elementary nature of my question, but could someone please explain the differences between these two database backup types:

1. Log backup
2. Log backup no truncate



From what I understand and have read, the "no truncate" backup method keeps the entire transaction log indefinitely. Using the truncation method, the transaction log is either 1) compressed or 2) cleaned up so that any completed transactions are removed from the log. Which one of these is true?


And, for the big question: is it better to run a backup of the transaction log with truncation or not? Our current backup scheme is similar to the following:


Full backup every 24 hours
transaction log backup every hour with no truncation


Should we insert a truncation backup somewhere in here? What is the danger of removing (or compressing) parts of the transaction log? Will this affect the restore process?


Thanks in advance!

View 6 Replies View Related

Cannot Truncate Due To Fks

Aug 1, 2007

i read that i can Truncate a table even if child table has no records so i tries to disable constraints but still can't get it to workCannot truncate table 'InventoryPC' because it is being referenced by a FOREIGN KEY constraint. disabling code on lines 9-13 and enabling codes on 36-40 1 ALTER PROCEDURE dbo.RevertDB
2
3 /* Reverts Database to original "Clean" State */
4 AS
5 SET NOCOUNT OFF
6 DECLARE @Log AS varchar(MAX), @RowsInDB AS int
7 SET @Log = 'RevertDB Started at ' + CAST(GETDATE() AS varchar(50)) + ''
8
9 /* *** Disable Constraints *** */
10 ALTER TABLE Booking NOCHECK CONSTRAINT ALL
11 ALTER TABLE InventoryPC NOCHECK CONSTRAINT ALL
12 ALTER TABLE PC NOCHECK CONSTRAINT ALL
13 ALTER TABLE Platform NOCHECK CONSTRAINT ALL
14
15 /* *** Start Truncates *** */
16 TRUNCATE TABLE Booking
17 SET @Log = @Log + 'Trucate Table Booking - Done' + ''
18 SET @RowsInDB = (SELECT COUNT(BookingID) FROM Booking)
19 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar(10)) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + ''
20
21 TRUNCATE TABLE InventoryPC
22 SET @Log = @Log + 'Trucate Table InventoryPC - Done' + ''
23 SET @RowsInDB = (SELECT COUNT(InventoryID) FROM InventoryPC)
24 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar(10)) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + ''
25
26 TRUNCATE TABLE PC
27 SET @Log = @Log + 'Trucate Table PC - Done' + ''
28 SET @RowsInDB = (SELECT COUNT(PCID) FROM PC)
29 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar(10)) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + ''
30
31 TRUNCATE TABLE Platform
32 SET @Log = @Log + 'Trucate Table Platform - Done' + ''
33 SET @RowsInDB = (SELECT COUNT(PlatformID) FROM Platform)
34 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + ''
35
36 /* *** Enable Constraints *** */
37 ALTER TABLE Booking WITH CHECK CHECK CONSTRAINT ALL
38 ALTER TABLE InventoryPC WITH CHECK CHECK CONSTRAINT ALL
39 ALTER TABLE PC WITH CHECK CHECK CONSTRAINT ALL
40 ALTER TABLE Platform WITH CHECK CHECK CONSTRAINT ALL
41
42 SET @Log = @Log + '*** End Truncates ***' + ''
43 /* *** End Truncates *** */
44
45 /* *** Start Insert Platform *** */
46 SET @Log = @Log + 'Start Insert Platform' + ''
47
48 EXEC dbo.InsertPlatform 'Windows XP SP2 Professional Edition', 'Some description for Windows XP SP2 Professional Edition over here …'
49 EXEC dbo.InsertPlatform 'Windows Vista Ultimate', 'See everything you''re working on more clearly with Windows Aero, and quickly switch between windows or tasks using Windows Flip 3D and Live Thumbnails. You can easily find what you need—when you need it―with Instant Search and live icon previews that display the actual contents of your files. And while you''re at it, give your personal productivity a boost with instant access to the information you care about using Windows Sidebar and Gadgets. Put these easy-to-use and customizable mini-applications on your desktop and reveal the information you''re looking for at a glance.Website: http://www.microsoft.com/windows/products/windowsvista/seeit/default.mspx'
50 EXEC dbo.InsertPlatform 'Apple Mac OS X Tiger', 'Some description for Apple Mac OS X Tiger over here …'
51 EXEC dbo.InsertPlatform 'Apple Mac OS X Leopard', 'Desktop: The new look of Leopard showcases your favorite desktop image and puts new file Stacks at your fingertips for a stunning, clutter-free workspace.Finder: Browse your files like you browse your music with Cover Flow.Time Machine: See how your system looked on any given day and restore files with aWebsite: http://www.apple.com/macosx/leopard/features/'
52 EXEC dbo.InsertPlatform 'Red Hat Linux', 'Some description for Red Hat Linux over here …'
53
54 SET @Log = @Log + 'Rows In Platform: ' + (SELECT COUNT(PlatformID) FROM Platform) + ''
55 /* *** Start Insert PC *** */
56 SET @Log = @Log + 'Start Insert PC' + ''
57
58 DECLARE @WinXP int, @WinVista int, @OSXTiger int, @OSXLeopard int, @RedHat int
59 SET @WinXP = (SELECT PlatformID FROM Platform WHERE Title = 'Windows XP SP2 Professional Edition')
60 SET @WinVista = (SELECT PlatformID FROM Platform WHERE Title = 'Windows Vista Ultimate')
61 SET @OSXTiger = (SELECT PlatformID FROM Platform WHERE Title = 'Apple Mac OS X Tiger')
62 SET @OSXLeopard = (SELECT PlatformID FROM Platform WHERE Title = 'Apple Mac OS X Leopard')
63 SET @RedHat = (SELECT PlatformID FROM Platform WHERE Title = 'Red Hat Linux')
64
65 EXEC dbo.InsertPC 'Fusion PC One', 'Description here ...', 'Intel Core2 Duo E6600 2.4 GHz 1066MHz', '1GB Dual Channel DDR2 667 SDRAM', '120GB SATA2 NCQ HDD', 'NVIDIA GeForce 8600 256MB GDDR3', '22" 3000:1 Wide Screen LCD', @WinXP
66 EXEC dbo.InsertPC 'Fusion PC Two', 'Description here ...', 'Intel Core2 Duo E6850 3 GHz 1333MHz', '2GB Dual Channel DDR2 800 SDRAM', '240GB SATA2 NCQ HDD', 'NVIDIA GeForce 8800 Ultra 256MB GDDR3 SLI', '24" 3000:1 Wide Screen LCD', @WinVista
67 EXEC dbo.InsertPC 'Fusion PC Three', 'Description here ...', 'AMD Athlon 64 X2 Dual Core 6000+ 3 GHz', '2GB Dual Channel DDR2 667 SDRAM', '240GB SATA2 NCQ HDD', 'ATI Radeon Cross Fire 2900 256MB GDDR3', '24" 3000:1 Wide Screen LCD', @WinVista
68 EXEC dbo.InsertPC 'Fusion X1', 'Description here ...', 'Intel Core2 Extreme Q6850 3 GHz 1333MHz', '6GB Dual Channel DDR2 800 SDRAM', '500GB SATA2 NCQ HDD', 'NVIDIA GeForce 8800 Ultra 256MB GDDR3 SLI', '30" 3000:1 Wide Screen LCD', @OSXLeopard
69 EXEC dbo.InsertPC 'Fusion X2', 'Description here ...', 'AMD Athlon 64 FX 74 3 GHz', '6GB Dual Channel DDR2 800 SDRAM', '500GB SATA2 NCQ HDD', 'NVIDIA GeForce 8900 Ultra SLI 256MB GDDR3', '30" 3000:1 Wide Screen LCD', @WinVista
70 EXEC dbo.InsertPC 'Fusion Tiger 1', 'Description here ...', 'Intel Core2 Duo E6600 2.4 GHz 1066MHz', '2GB Dual Channel DDR2 800 SDRAM', '120GB SATA2 NCQ HDD', 'NVIDIA GeForce 8600 256MB GDDR3 SLI', '22" 3000:1 Wide Screen LCD', @OSXTiger
71 EXEC dbo.InsertPC 'Fusion Linux 1', 'Description here ...', 'AMD Athlon 64 X2 6000+ 3 GHz', '1GB Dual Channel DDR2 800 SDRAM', '120GB SATA2 NCQ HDD', 'NVIDIA GeForce 8600 256MB GDDR3', '22" 3000:1 Wide Screen LCD', @RedHat
72
73 SET @Log = @Log + 'Rows In PC: ' + (SELECT COUNT(PCID) FROM PC) + ''
74
75 /* *** Start Insert Inventory *** */
76 SET @Log = @Log + 'Start Insert Inventory' + ''
77
78 DECLARE @F1 int, @F2 int, @F3 int, @FX1 int, @FX2 int, @FT1 int, @FR1 int
79 SET @F1 = (SELECT PCID FROM PC WHERE Title = 'Fusion PC One')
80 SET @F2 = (SELECT PCID FROM PC WHERE Title = 'Fusion PC Two')
81 SET @F3 = (SELECT PCID FROM PC WHERE Title = 'Fusion PC Three')
82 SET @FX1 = (SELECT PCID FROM PC WHERE Title = 'Fusion X1')
83 SET @FX2 = (SELECT PCID FROM PC WHERE Title = 'Fusion X2')
84 SET @FT1 = (SELECT PCID FROM PC WHERE Title = 'Fusion Tiger One')
85 SET @FR1 = (SELECT PCID FROM PC WHERE Title = 'Fusion Linux One')
86
87 EXEC dbo.InsertInventory 10, @F1, 2.5, 'iCluster Fusion One'
88 EXEC dbo.InsertInventory 10, @F2, 2.5, 'iCluster Fusion Two'
89 EXEC dbo.InsertInventory 10, @F3, 2.5, 'iCluster Fusion Three'
90 EXEC dbo.InsertInventory 6, @FX1, 6, 'iCluster Fusion X1'
91 EXEC dbo.InsertInventory 6, @FX2, 6, 'iCluster Fusion X2'
92 EXEC dbo.InsertInventory 10, @FT1, 3, 'iCluster Fusion Tiger One'
93 EXEC dbo.InsertInventory 30, @FR1, 2, 'iCluster Fusion Linux One'
94
95 SET @Log = @Log + 'Rows In Inventory: ' + (SELECT COUNT(InventoryID) FROM InventoryPC) + ''
96
97 RETURN @Log
98
   

View 1 Replies View Related

Truncate Log

Nov 23, 1999

I would like to ask if I backuped the transaction log already, SQL will truncate the transaction log automatically or not. If not what should I do?

View 1 Replies View Related

Truncate Log

Nov 19, 2001

Is there an ISQL statement to truncate the transaction log??? A Stored Procedure maybe?

View 4 Replies View Related

SQL CE 200 And TRUNCATE

Jan 8, 2005

I have two tables in my SQL CE database. tblTempData and tblBatchData. When the user wants to move the data from 'temp' into 'batch' I would like to truncate the 'temp' table. When I do this I get the unable to parse query error.

strSQL = "TRUNCATE TABLE tblTempData"
goADOcn.Execute (strSQL)

Is there something that I am doing wrong, or is TRUNCATE not supported in SQLCE 2000?

View 2 Replies View Related

Truncate?

Dec 29, 2005

can TRuncate statement be rolled back ?

View 5 Replies View Related

Truncate Log

May 1, 2006

Does anyone know how to truncate log without grow up space used?

Thanks
Sbahri

View 4 Replies View Related

Truncate Log

May 13, 2004

Hi there,

I have a simple stored procedure that will truncate the log file but I now need to make this dynamic so that this proc can be run with any DB name. I know you can look up the logical filename in sysfiles but I'm not too sure how to write this procedure so that it will simply truncate the log file of the currently selected DB.

This is what I have so far which as you can see is hardcoded:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS OFF
GO


CREATE PROCEDURE TruncateLog AS

BACKUP LOG [FICaches] with TRUNCATE_ONLY


DBCC SHRINKFILE (FICaches_log, 50)


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Any help would be greatly appreciated!

Thanks

NewToSql

View 2 Replies View Related

Truncate Log

May 13, 2008

Hi

I have a Log which is 15 gb. Recovery mode is simple.

What command can I use to truncate this log? Or is it best to shrink it?

Thanks

View 4 Replies View Related

Truncate

May 26, 2008

I have a small doubt .
Truncate is not a logged operation.
In log shipping if we perform any truncate operation on the primary server will its get reflected on the secondary server.

View 2 Replies View Related

Truncate

Jun 13, 2008

I have 2 tables.
Table 1 and table 2.
Table 1 has a foreign key related to a particular column on table 2.
Suppose if i have applied a truncate command on table 2 .will it work or not.
We have to check for dependencies on the table before we should apply a truncate command.

Could any one tell me can we directly apply a truncate command on any object irrespective of the dependencies on that object.

View 2 Replies View Related

Truncate Log

Dec 13, 2007

How to setup a sql 2005 maint plan for truncate log ?
Is it possible or do need to create a job and and in job step mention below
Backup log DatabaseName with truncate_only


How do i issue the checkpoint?
...please let me know?

View 5 Replies View Related

Truncate Log

Dec 14, 2007

I need to truncate log for one DB
do i need to create a job and and in job step mention below
Backup log DatabaseName with truncate_only

is there any other way to do this?


How do i issue the checkpoint?
...please let me know?

View 10 Replies View Related

How To Truncate A Str???

Mar 22, 2007

Hello All,



I am doing some data extraction from a database table: custtable. The customers have zip codes of 9 digits however I just need the first five of them. I am not sure of the syntax. Can anyone suggest me on this one?

This is what my statement is

where ((len (ct.zipcode ) > 5 and ct.country = '001')or ct.country <> '001')

This one returns customers with zipcodes > 5 and I need to only truncate this, coz my database also contains cust with zip code of only 5 digits and I have extracted that data already. Now I need all the zipcodes that have a length of 9 to be truncted to 5.



An earliest possible response is highly appreciable.



Thanks,

Rashi

View 5 Replies View Related

Truncate Log

Dec 14, 2007

How to setup a sql 2005 maint plan for truncate log ?
Is there any other way to do this?

View 4 Replies View Related

Truncate Table

Jul 4, 2007

i did a Stored Procedure to truncate a table. it contains lots of crap from testing the site. just a simple 1 ALTER PROCEDURE dbo.TruncateUploads

AS
TRUNCATE TABLE Uploads but it says "Cannot truncate table 'Uploads' because it is being referenced by a FOREIGN KEY constraint." then i make NULL all foreign keys and try still cannot. then i did it manually deleting all records then can! but why can't i truncate it? isn't it the same as removing all values plus having the primary keys to start from 0? 

View 5 Replies View Related

How Can I TRUNCATE My Table?

Oct 27, 2007

How can i TRUNCATE my table (removes rows that were produced at testing), so that in the actual running the automated IDNumber for my table start with 1.

View 6 Replies View Related

Truncate The Zeros

Jan 9, 2004

Hi all,
I have a problem.
The SQL statement I have is like this

select * from table where (convert varchar(25),AMT) LIKE '%0%'
This causes all my data to appear instead of 1 only if I key 77 into the textbox because AMT is a currency type with 77.000.
So is there another way of solving this other than truncating off the zeroes?

If so feel free to assist me, your help is greatly appreciated.
Thanks.

View 4 Replies View Related

Truncate Permission

Sep 6, 2001

Hi

Is there a way to give a user a Truncate permission on a table without being in sysadmin role or dbo.

Thanks

View 1 Replies View Related

Allow Data To Truncate

Nov 6, 2001

Hi,

I'm using SQL 7. Is there a way I can allow data to be truncated? I'm trying to insert a 50 length column into a 40 length column. I need to truncate the data to prepare for exporting to a fixed field format.

Any Suggestions?
Thanks,
Denise

View 1 Replies View Related

Truncate Table

Nov 1, 2000

hi, I have two tables members table and orders table.
I have 2 records in members table and zero records in order table.
When I try to truncate members table I get an error message.
cannot truncate table members,because it is being referenced by a FOREIGN KEY constraint.

this what blows my head, There is no records in orders table. so why would the constraint enforced when there is no data in the order table. I created same table in access and I was able to delete a member from the members table. any comments.

thanks
Ahmed

View 4 Replies View Related

** Trans Log Won&#39;t Truncate **

Oct 16, 2000

SQL7:

I have a 300MB db, and a transaction log near 1.3GB. Upon notification, I backed up the db log with truncate_only - no luck getting it smaller. Later, tried backup with no_log ( assuming the o/s was full - no diff)

I tried shinkfile (logfile,truncateonly) and no luck.

I tried dbcc opentrans to see if any pending trans. The db looks fine with dbcc checkdb. I managed to free up a mere 50MB. I checked the permissions on the db, and added backup db, and backup log in the db permissions for the user logged in (also tried this with sa)

I am unable to free up the space to the os. Can I somehow rid the log file and start off with a fresh log file? I need this space. As a patch I moved the log to a larger filesystem as a temporarily fix.

start/stop SQL- nothing? reboot -nothing? I played with waiting game. This log does not want to release space. The log grew from data loads.

Question1: Suggestions how to truncate this log? The contents are not really impt, but the space is.

Question2: Can I add another logfile, then use EMPTYFILE to transfer the contents to the newly added log file, then REMOVE The original logfile? In theory does this make sense?

Thanks,
Jason

View 5 Replies View Related

Truncate Log Before Backup

Jan 14, 2000

how do i modify this so that it will truncate the log before backup?

SQLMAINT.EXE -D mimi-BkUpDB E:SQLBackups -BkUpMedia DISK -DelBkUps 1 -Rpt E:SQLMaintmimi_maint.rpt

thanks

View 1 Replies View Related







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