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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to write fast insert statement

Author  Topic 

NgKH
Starting Member

15 Posts

Posted - 2003-04-02 : 12:02:04
how do you do an insert into table <A> select b.1, c.2 from b, c, where...
statement such that it writes minimal to transaction log.. performancewise.. it is faster? Assume A has just been created with no contents, or just been truncated

i know that instead of delete all records in a table you can simpily truncate it.. truncate the table won't logs transaction logs.. are there some kind of simular ways for insert?


nr
SQLTeam MVY

12543 Posts

Posted - 2003-04-02 : 12:49:32
No.

The truncate just logs the deallocation of the pages there isn't an equivalent for insert or update.

You can do a non-logged bcp to insert data though. A bcp out + bcp in may be faster that an insert for a lot of data.

Truncate is usually a bad idea too as it affects permissions, backups, database setup, ...

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Bambola
Posting Yak Master

103 Posts

Posted - 2003-04-02 : 14:37:58
quote:

Truncate is usually a bad idea too as it affects permissions, backups, database setup, ...



How does it affect permissions etc?

Bambola.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-04-02 : 14:51:12
From bol
TRUNCATE TABLE permissions default to the table owner, members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles, and are not transferable.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -