473,804 Members | 4,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Truncate table

Hi
I want to truncate all data in database ... pls help me how i ll
truncate?

Dec 16 '06 #1
14 12298

Sala wrote:
Hi
I want to truncate all data in database ... pls help me how i ll
truncate?
Sala wrote:
I am using sql server 2000..
Dec 16 '06 #2

Sala wrote:
Hi
I want to truncate all data in database ... pls help me how i ll truncate?
Do you really mean "truncate"? Truncate typically means that you trim
extra blank space from the ends of character strings. It doesn't sound
like that is what you want to do.

Do you mean "delete"? If so, you have to tell us whether you want to
delete all rows in all tables (leaving the database table structure
intact, but with no data), or you want to drop all tables from the
database, leaving the database empty, without tables or data. The
correct term for the first is "delete" (rows of data), while the
correct term for the second is "drop" (tables).

So... what is it you want to do?

Dec 16 '06 #3
On 15 Dec 2006 23:58:45 -0800, Sala wrote:
Hi
I want to truncate all data in database ... pls help me how i ll
truncate?
The truncate statement works as follows:

truncate table TableName

So all you need to do is run it for each of the tables in your database.
You'd probably put this in a stored procedure to make it easier to run
subsequently.

However there are caveats -- you can't use it to on tables that are
replicating, for instance

--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 16 '06 #4
Bruce Wood wrote:
Sala wrote:
> I want to truncate all data in database ... pls help me how i ll truncate?

Do you really mean "truncate"? Truncate typically means that you trim
extra blank space from the ends of character strings. It doesn't sound
like that is what you want to do.

Do you mean "delete"? If so, you have to tell us whether you want to
delete all rows in all tables (leaving the database table structure
intact, but with no data), or you want to drop all tables from the
database, leaving the database empty, without tables or data. The
correct term for the first is "delete" (rows of data), while the
correct term for the second is "drop" (tables).

So... what is it you want to do?
He probably want to do a TRUNCATE !

http://msdn2.microsoft.com/en-us/library/ms177570.aspx

Arne
Dec 16 '06 #5
Rad [Visual C# MVP] wrote:
On 15 Dec 2006 23:58:45 -0800, Sala wrote:
>Hi
I want to truncate all data in database ... pls help me how i ll
truncate?

The truncate statement works as follows:

truncate table TableName

So all you need to do is run it for each of the tables in your
database. You'd probably put this in a stored procedure to make it
easier to run subsequently.

However there are caveats -- you can't use it to on tables that are
replicating, for instance
Or on tables that are the target of foreign keys in other tables - even if
those other tables are empty!

-cd
Dec 16 '06 #6

Arne Vajhøj wrote:
Bruce Wood wrote:
Sala wrote:
I want to truncate all data in database ... pls help me how i ll truncate?
Do you really mean "truncate"? Truncate typically means that you trim
extra blank space from the ends of character strings. It doesn't sound
like that is what you want to do.

Do you mean "delete"? If so, you have to tell us whether you want to
delete all rows in all tables (leaving the database table structure
intact, but with no data), or you want to drop all tables from the
database, leaving the database empty, without tables or data. The
correct term for the first is "delete" (rows of data), while the
correct term for the second is "drop" (tables).

So... what is it you want to do?

He probably want to do a TRUNCATE !

http://msdn2.microsoft.com/en-us/library/ms177570.aspx
Ahhh! Shows how much I know, doesn't it? :-)

Dec 16 '06 #7
On 15 Dec 2006 23:58:45 -0800, "Sala" <sa**********@g mail.comwrote:
>Hi
I want to truncate all data in database ... pls help me how i ll
truncate?
Actually that is not a C# question.

Why not try: microsoft.publi c.sqlserver.new users?

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Dec 17 '06 #8
And the winner is.. Otis! This question had absolutely nothing to do with C#
language issues.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Otis Mukinfus" wrote:
On 15 Dec 2006 23:58:45 -0800, "Sala" <sa**********@g mail.comwrote:
Hi
I want to truncate all data in database ... pls help me how i ll
truncate?

Actually that is not a C# question.

Why not try: microsoft.publi c.sqlserver.new users?

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Dec 17 '06 #9
On Sat, 16 Dec 2006 17:22:00 -0800, Peter Bromberg [C# MVP]
<pb*******@yaho o.nospammin.com wrote:
>And the winner is.. Otis! This question had absolutely nothing to do with C#
language issues.
Peter
Thanks, Peter!

Where do I go to collect the prize? ;o)

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Dec 20 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
16046
by: Ed | last post by:
I am trying to get some information to compare and contrast the Truncate Table function and the Drop Table function. I know that using Truncate Table is faster and saves the structure of the table while the Drop Table will delete the table totally (data and structure). My question is whether using one function over the other will use up more capacity on the server? Ed
3
4528
by: martin | last post by:
Hi, We have a heavily used production server and a table which logs every hit on a web site. This table has grown large over time and we want to clear it down as efficiently as possible. We would like to issue a truncate table statement, but with millions of rows we are a bit wary of how this will affect server performance. The alternative is to delete is stages using rowcount but of course this will generate a large amount of logging....
3
8662
by: LineVoltageHalogen | last post by:
Greeting All, I have a stored proc that dynamically truncates all the tables in my databases. I use a cursor and some dynamic sql for this: ...... create cursor Loop through sysobjects and get all table names in my database. .... exec ('truncate table ' + @TableName)
5
3111
by: ronin 47th | last post by:
Hi group, In one of the books 'Gurus Guide to Transact SQL' i found this info: ------------------------------------------------------------ TRUNCATE TABLE empties a table without logging row deletions in the transaction log. It can't be used with tables referenced by FOREIGN KEY constraints, and it invalidates the transaction log for the entire database. Once the transaction log has been invalidated, it can't be backed up until the...
2
48062
by: rdraider | last post by:
Hi, I am trying to create a script that deletes transaction tables and leaves master data like customer, vendors, inventory items, etc. How can I use TRUNCATE TABLE with an Exists? My problem is I have 200+ tables, if I simply use a list like: truncate table01 truncate table02 truncate table03 ....
9
14695
by: Sumanth | last post by:
Are there any implementations of truncate in db2. Is it going to be implemented in the future? Is there an alternate way of doing a truncate of a table that has a high record count without using "load" and is fast? Thanks, Sumanth
6
13119
by: pramod | last post by:
Hi I know we can truncate a table in DB2 by first creating it with NOT LOGGED INITIALLY option. and when we need to truncate it, run the following command alter table <table name> activate not logged initially with empty table My question is: 1. Do we have to connect to the database with auto-commit off every
2
18719
by: Neil | last post by:
Can one use Truncate Table on a linked server table? When I try it, I get a message that only two prefixes are allowed. Here's what I'm using: Truncate Table svrname.dbname.dbo.tablename
10
13890
by: Troels Arvin | last post by:
Hello, Until this date, I believed that DB2 has no TRUNCATE TABLE command. But then I came across http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/c0023297.htm where it says: After an ALTER TABLE statement containing REORG-recommended operations, you can execute only the following statements on a table:
8
7718
by: ananthaisin | last post by:
How to reduce the table size for any table while using truncate or delete statements. In oracle 8i it was truncating the storage space but in 10g it is not .... I have given truncate statement in a procedure to drop the storage of a table used... when its record count exceeds 500. BEGIN i:= 0; FOR CC IN NLD LOOP
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10320
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.