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 |
|
ankurgupta26
Starting Member
32 Posts |
Posted - 2002-09-27 : 07:36:01
|
| Hi,I have a scripts that downloads data froman external database to the one that I am using.The script goes like this.....Truncate ExtTable1Insert into IntTable1select * from ExtTable1Truncate ExtTable2Insert into IntTable2select * from ExtTable2...and so on for about 10 such tables. Each table has about more than 100,000 records.Recently my DBA asked me to replace truncate with delete because truncate requires extra privileges. When I did that and ran the scripts there was a tremendous increase in the size of the log file.So we reverted back to truncate. Now, the dba wants that each of the above sql should be included with a transaction somee what like this...begin tranTruncate ExtTable1Insert into IntTable1select * from ExtTable1commitbegin tranTruncate ExtTable2Insert into IntTable2select * from ExtTable2commitI was just wondering whether explicitly stating the begin tran...commit will help ...as the default mode of SQL server is autocommit... in reducing the size of the log fileThanks !AnkuR. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-09-27 : 07:42:56
|
| Why does he want to do that?He is right to be concerned about giving rights to do a truncate though. It also means that you can never use transaction log backups in that database.Suggest that you create a new database for the import process on which your process can have permissions to do the truncate and on which the transaction log is truncated on checkpoint.Then you don't have any problems and can access the table from the other database afterwards.And it won't cause any trouble if this database gets corrupted as it doesn't hold any permanent data.Don't bother with the transaction maybe something likeTruncate ExtTable1if exists (select * from ExtTable1)begin raiserror returnendInsert into IntTable1 select * from ExtTable1 if @@error <> 0begin raiserror returnend==========================================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.Edited by - nr on 09/27/2002 07:43:41 |
 |
|
|
ankurgupta26
Starting Member
32 Posts |
Posted - 2002-09-27 : 08:29:58
|
| Thanks for your reply...Can you tell what does this statement mean "transaction log is truncated on checkpoint"Thanks !AnkuR. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-09-27 : 09:12:20
|
| In v2000 it's called simple recovery model.It means the transaction log isn't saved - they are deleted up to the earliest active transaction on every checkpoint. It keeps the transaction log small (unless something goes wrong) and makes the database easier to administer - and allows non-logged operations.==========================================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. |
 |
|
|
|
|
|