September 16, 2005 at 4:51 am
Using SQL 7
Question: will the database automatically truncate the field to the size of the data stored in it, or will every entry/field have potentially 4000 empty characters and also have the potential to run slow when lots of data is stored and retrieved?
I'm storing data that could be 1-4000 characters and presumably most data will be much smaller than 4000 characters. I just don't want to run into problems with speed and efficiency after a few thousand (tens of thousands?) records are entered, but obviously like having the flexibility of not limiting it to 300-500 characters or having multiple tables to deal with.
Thanks in advance.
Jason
September 16, 2005 at 7:49 am
Varchar will only store the actual data removing trailing white space, conserving diskspace in the process.
September 16, 2005 at 8:12 am
Varchar will only store the actual data... |
True.
declare @test-2 varchar(4000)
set @test-2='abc '
will only store 6 characters (plus small overhead for string length)
...removing trailing white space... |
False.
declare @test-2 varchar(4000)
set @test-2='abc '
will store 6 chars including the 3 trailing spaces
select datalength(@test) will return 6
conserving diskspace in the process |
True.
char(4000) will store 4000 characters and will pad with trailing spaces declare @test-2 char(4000)
set @test-2='abc '
will store 4000 chars including the trailing spaces
select datalength(@test) will return 4000
Note len returns the length of varchar ignoring trailing spaces
declare @test-2 varchar(4000)
set @test-2='abc '
select len(@test) will return 3
Far away is close at hand in the images of elsewhere.
Anon.
September 16, 2005 at 10:03 am
Please don't cross post: http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=169&messageid=220550
People look at many forums.
Thanks
I wasn't born stupid - I had to study.
September 16, 2005 at 10:13 am
Are you trying to start an infinite loop???
Post the link back to this post but not from this one to the cross one .
September 16, 2005 at 11:00 am
Scroll down for answer...
Scroll up for answer...
I wasn't born stupid - I had to study.
September 16, 2005 at 4:33 pm
lol, nice one Farrell.
About time someone got one up on remi
Far away is close at hand in the images of elsewhere.
Anon.
September 16, 2005 at 9:30 pm
You think I'm actually stupid enough to fall for that one???
September 19, 2005 at 4:23 am
At least not a third time....
(lighten up.., I was only kidding... bully )
I wasn't born stupid - I had to study.
September 19, 2005 at 7:11 am
I know... wanted to increase the post count by one more .
September 19, 2005 at 9:50 am
We all can do that
Far away is close at hand in the images of elsewhere.
Anon.
September 19, 2005 at 11:00 am
We can?
(poor Jason Carlson if he is getting emailed on this...)
I wasn't born stupid - I had to study.
September 19, 2005 at 11:20 am
Who is he?
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply