i'd like to know why if i created a temp table out of my procedure the insert into it get slower than if i create that temp table inside my procedure. follows an example:
createtable#Test (col1 varchar(max))
gocreateproc dbo.testasbegintruncatetable#Testinsertinto#Testselect'teste'FROM sys.tablescrossjoin sys.columnsend
goexec dbo.test
gocreatetable#Test2 (col1 varchar(max))
gotruncatetable#Test2insertinto#Test2select'teste'FROM sys.tablescrossjoin sys.columns
At test, we get duration 71700, reads 45220, CPU 26052 At test2, we get duration 49636, reads 45166, cpu 24960
best regards