trancate

  • hello,

    what is trancate?

    how should i do it?

    thanks

  • Do you mean TRUNCATE?

  • Perhaps it would be better for you to describe what you are trying to do.

  • Yes,

    Yes.

  • TRUNCATE is a way of removing all data from a table.

    What are you trying to do?

  • Yes,

    Yes.

  • i want to remove all rows , then modify my table deign, how can i use Truncate?

  • TRUNCATE TABLE [TableName]

    This will remove all rows from the table. TRUNCATE is a non-logged operation, so if you are using log shipping or have regular log backups running, it can cause you some issues. It is also pretty much instant.

    There is also no un-do on this, these records will be gone forever.

  • If you are interested in the internals of what is happening that is different than:

    DELETE [TableName]

    I recommend you read the TRUNCATE and DELETE topics in books online.

  • Michael Earl (12/22/2008)


    TRUNCATE is a non-logged operation, so if you are using log shipping or have regular log backups running, it can cause you some issues.

    Not at all.

    Truncate table is minimally logged. The page deallocations are logged, the rows are not. Hence log shipping and log backups aren't affected, it can also be rolled back if run within an explicit transaction.

    Transactional replication won't allow a truncate, because of the way it moves transactions around.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Don't bite my head off Gail, just wanted to make the point that it is logged "differently" without typing out a lot of detail.

    It's a holiday week - need to save my energy.

  • Michael Earl (12/22/2008)


    Don't bite my head off Gail,

    Not biting anything

    just wanted to make the point that it is logged "differently" without typing out a lot of detail.

    Sorry, it's just a common myth that Truncate is not logged and breaks log chains, log shipping, etc, etc

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • TRUNCATE is a non-logged operation, so if you are using log shipping or have regular log backups running, it can cause you some issues.

    sorry what do you mean by non-logged operation?

  • about Writing Truncate only i should open a new quer and write

    Truncate Servername.Databasename.dbo.Tablename

    in it ?

  • nazaninahmady_sh (12/22/2008)


    i want to remove all rows , then modify my table deign, how can i use Truncate?

    If all you are trying to do is change the structure of the table, you do not have to get rid of the data to do this.

    Is this a table you created and are trying to change? Is the existing data of no use?

    Steve

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic. Login to reply