Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Drop data not structure

Author  Topic 

26SQLserver
Starting Member

3 Posts

Posted - 2010-06-21 : 03:43:11


Hi all,

i am new to SQL server, infact i am Oracle DBA, but our new project about sending data of table from Oracle Database ot SQl server database periodically, so my question is

How can i delete Data of table in SQl Server 2005 not Structure of the table?

Quick response will be higly Appreciated. thanks a lot in advance

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-06-21 : 04:13:57
Look up TRUNCATE TABLE in SQL's books Online (SQL help file)

--
Gail Shaw
SQL Server MVP
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-06-21 : 04:14:35
If you want a non logged delete, use TRUNCATE TABLE, if you want it logged, use DELETE FROM
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-06-21 : 05:18:12
Truncate is only possible if your table doesn't have any foreign key references. Script out all the foreign keys, then drop them and then run the results of this query in your database:

SELECT 'TRUNCATE TABLE [' + table_name + ']' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-06-21 : 06:54:31
quote:
Originally posted by RickD

If you want a non logged delete, use TRUNCATE TABLE, if you want it logged, use DELETE FROM



Truncate is a logged operation. There are no unlogged data changes in SQL Server.

Truncate logs page deallocations rather than row deletions, that's why it has less of a log impact, but it is still a logged operation.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -