January 18, 2013 at 5:09 am
Hi all, happy new belated year.
I have the need to store text/number in a column in MSSQL DB but I not sure which data type would be best. I have found that having a fixed length works but also waste's alot of space, text is the same. If the length varies which data type would yuo suggest to use.
Jay
January 18, 2013 at 6:00 am
varchar() or nvarchar()
______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience
January 18, 2013 at 6:09 am
varchar() or nvarchar()
varchar(max) or varchar(x) is there no variable field, as varchar(50) will always use 50 spaces or however you call them.
This does seem a really noob question and I apologize
Jay
thanks
January 18, 2013 at 6:12 am
jerome.morris (1/18/2013)
s varchar(50) will always use 50 spaces or however you call them.
No it doesn't.
Char(50) always uses 50 bytes, varchar(50) uses as much space as the data in it (plus a 2 byte overhead), so if you have 10 characters in a varchar(50) column, that takes 12 bytes to store. Varchar is the variable length column type.
Varchar(max) is for when you're storing over 8000 characters in a column (up to 2.1 billion)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 18, 2013 at 6:17 am
GilaMonster (1/18/2013)
jerome.morris (1/18/2013)
s varchar(50) will always use 50 spaces or however you call them.
Sorry I wasnt stating it does I was unsure. Thanks for your explanation
Jay
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply