Showing posts with label indexing. Show all posts
Showing posts with label indexing. Show all posts

Friday, February 17, 2012

delete or drop table then create table

which one is smarter, where there is no indexing on the table which is really simple table delete everything or recreate table. I got an argument with one of my coworker. He says it doesnt matter i say do delete. Any opinions.DELETE is a logged transaction, and so incurs overhead that DROP and RECREATE do not.
For another option, try TRUNCATE table, which is also unlogged.|||well said i did research truncate table and you are of course correct on this. I'll change the code to that :D|||delete *

You crack me up|||Why don't you show us what you're doing, what volume, ect

Where for example are you getting the data from...and if you got into an argument, what did your coworker say?|||Personally I would not allow the drop/create table here, as it carries too many permission implications. Take the matter of the logs up with the DBA involved, and see if the transaction logs will hold up. He may need to add more diskspace, more backups, or both.|||delete *
You crack me upThat's MS Access syntax...|||Heres the code i made

if 0< (select count(*) from dbo.sysobjects where id = object_id(N'[dbo].[_Bootfiles_Summary_Work_Table]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
TRUNCATE TABLE _Bootfiles_Summary_Work_Table
end
else
begin
Create Table _Bootfiles_Summary_Work_Table
(Agency smallint,
Plate_State varchar(20),
Plate varchar(8),
Cite_Count int,
CiteBalance Money)
end

its really simple actually no index no nothing, and in case it gets deleted some code that i dont know this is will recreate the table.

and o yea no star on the delete my mistake.