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.
Author |
Topic |
lorellana
Starting Member
25 Posts |
Posted - 2011-09-24 : 15:39:22
|
I would like to use the command: use sybsecuritygotruncate table sysaudits_01but the where clause, it's possible? Thanks you. |
|
lorellana
Starting Member
25 Posts |
Posted - 2011-09-24 : 15:40:44
|
I do not want to delete all records, only from a particular date. |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-09-24 : 17:23:00
|
Use DELETE rather than TRUNCATE if you want to delete specific records.DELETE DFROM MyTable AS DWHERE MyDateColumn < 'yyyymmdd' -- the cutoff date Take a backup first |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-09-24 : 17:59:01
|
If that's a large amount of rows, it may be necessary to do the delete in chunks, a few thousand rows at a time. If that's the case the delete takes a TOP clause. DELETE TOP (20000) FROM ...--Gail ShawSQL Server MVP |
|
|
Cindyaz
Yak Posting Veteran
73 Posts |
Posted - 2011-09-29 : 10:18:08
|
Truncate removes all rows from the table. There is no 'where' clause to it. Use Delete as suggested above to delete rows based on some condition. |
|
|
anita.86
Starting Member
21 Posts |
Posted - 2011-12-09 : 02:40:26
|
truncate command delete all records, for particular record u have use DELETE FROM TABLENAME WHERE 'YOUR CONDITION'N/A |
|
|
|
|
|