truncate table

  • Hi,

     

    I've been informed that the truncate table command is no longer supported in SQL 2005.

    Could anyone tell me what it's been replaced by?

  • Hi Mark,

    Who said that it is not supported in SQL 2005??

    Check the SQL 2005 help.

    Thanks

     


    Lucky

  • i'd speculate that someone tried to truncate a table that was referenced by a foreign key, got an error, and assumed that it was not supported;

    truncate table deletes all the data in the table, and resets the indentity function, if it existed on one of the columns, back to 1.

    like Lucky said, it is most certainly supported, but since you can't truncate a table referenced by a foreign key, you need to reinitialize the identity column instead.

    in Win2K and SQL 2005 the command islike this:

    DBCC CHECKIDENT( [#sometable],RESEED,newintvalue)

    reseed starting at 1 again:

    DBCC CHECKIDENT( [#sometable],RESEED,1)

    reseed, but starting at 99 instead:

    DBCC CHECKIDENT( [#sometable],RESEED,99)

     

     

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 2 (of 2 total)

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