Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
DBADave
Constraint Violating Yak Guru
366 Posts |
Posted - 2009-09-17 : 09:12:23
|
I was reviewing developer code yesterday and found a lot of code that created temp tables using varchar(8000) for any variable length column. I've always felt this is a bad idea, but no longer recall the reasons why this should be avoided. What are some of the reasons why you should not always declare a variable length column as varchar(8000) or varchar(max)?I created a small script to demonstrate how code runs slower when declaring temp table columns as varchar(8000) and then inserted and updated 100,000 records. I re-ran the script with the columns declared as varchar(8). I saw little difference in perfomance with inserts, but updates produced a big difference in run time. Now I need to explain why varchar(8000) causes overhead if the data could fit in a much smaller varchar column.Thanks, Dave |
|
|
|
|