Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Char(100) field VS Text
Message
 
 
To
19/04/2012 11:49:40
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01542085
Message ID:
01542135
Views:
18
>>Yes, for the new field definitely go with the varchar to save space. BTW, for smaller size fields the gain is not that obvious. It is shown for big char fields, say, 15 char and up.
>
>That would be at least that. Because, this is to support the addition of caption on images. So, we will read that from XML. I assume between 25 and 50.
>
>>Yes, that's correct as I just verifed it with this script:
>>
>>
>>use tempdb 
>>
>>create table Test (ch char(10))
>>insert into Test values ('d'),('b'),('c')
>>
>>alter table test alter column ch varchar(10)
>>
>>select CH, REPLACE(ch,space(1),'-') as Verified from Test
>>
>>I think I need to read more in BOL on this topic as perhaps there is an option to immediately remove extra space.
>
>Ok, I am not familar with that REPLACE syntax, but I assume it blanks out the field.
>
>Yes, if there would be something built in to achieve the same, it would be great.
>
>Thanks for providing the example on this topic.

I used REPLACE command to demonstrate that the spaces are still intact after the switch. As Dan suggests, if you need to change char to varchar after the fact, the better way is to create new structure and re-load the table.

REPLACE command in T-SQL is the same as STRTRAN in VFP.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform