I use the following code to import a table from an Oracle DB to SQL Server every day:
TRUNCATE TABLE mytable
INSERT INTO mytable (firstname, lastname, city, state)
SELECT * FROM OPENQUERY (mylinkedserver, 'SELECT firstname, lastname,
city, state FROM mylinkedtable')
The above causes massive fragmentation (90% to 99%) on my nonclustered indexes on "mytable". If I run the below code
SELECT * INTO mytesttable
FROM mytable
TRUNCATE TABLE mytable
INSERT INTO mytable
SELECT * FROM mytesttable
DROP TABLE mytesttable
I end up with fragmentation of between 1% and 3% on my nonclustered indexes. What is causing this? Both statements are truncating the table and inserting new data into a blank table.