Truncate Table

  • not really a frequent usage, but an interesting question

  • Good question but neither answer was correct. Granted you do NOT get an error but the truncate does not technically run either. If you go back and view the table data you will see that data has not been removed.

  • bgdjwoods (4/30/2013)


    Good question but neither answer was correct. Granted you do NOT get an error but the truncate does not technically run either. If you go back and view the table data you will see that data has not been removed.

    Don't know what you are doing, but I added a couple of selects and it sure looks like the data is gone to me:

    CREATE TABLE dbo.Test

    (

    Col_1 INT PRIMARY KEY

    ,Col_2 INT REFERENCES Test(Col_1)

    ,Col_3 INT IDENTITY

    )

    ;

    INSERT INTO dbo.Test VALUES (1,1);

    INSERT INTO dbo.Test VALUES (2,2);

    INSERT INTO dbo.Test VALUES (3,3);

    GO

    select * from dbo.Test;

    go

    TRUNCATE TABLE Test;

    GO

    select * from dbo.Test;

    go

    drop table dbo.Test;

    go

  • Yeah, you were right about the foreign key and deletion.

Viewing 4 posts - 31 through 33 (of 33 total)

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