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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 varchar size

Author  Topic 

colgie
Starting Member

18 Posts

Posted - 2010-07-07 : 09:18:11
I am using SQL SERVER 2005 and I need to store strings in it from very short up to about 250 characters. I am using VARCHAR() to define the length. Does it matter from the performance point of view how big I set them or can I set them all way too big to ensure that stings do not exceed them. I am also making sure they are not exceeded by scripts in the input routines but wondered if setting large VARCHAR limits actually created large fields even if they were empty and impaired performance or indeed if there were any other reasons why I should not.
Thanks for any help on this

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-07 : 09:25:47
... but wondered if setting large VARCHAR limits actually created large fields even if they were empty ...
No, don't worry about that. Varchar takes only the needed space.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

colgie
Starting Member

18 Posts

Posted - 2010-07-07 : 09:52:13
So just to clarify - I could use VARCHAR(MAX) on all my fields without a problem??
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-07 : 09:59:46
It depends.
Look here:
http://www.sqlservercentral.com/Forums/Topic807783-338-1.aspx


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

colgie
Starting Member

18 Posts

Posted - 2010-07-07 : 10:16:42
Thanks - that explains it
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-07 : 10:17:32
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -