We are doing a Visual Foxpro (DBF) to SQL Server conversion, but will retain the VFP GUI to now use the SQL Server database.
我们正在进行Visual Foxpro(DBF)到SQL Server转换,但是将保留VFP GUI以便现在使用SQL Server数据库。
In several memo fields in VFP, we store a mix of ASCII characters and text.
在VFP的几个备忘录字段中,我们存储了ASCII字符和文本的混合。
What would be the best column datatype to store these values preferably without having to CAST?
什么是最好的列数据类型来存储这些值,最好不需要CAST?
Along these same lines, we also have times when we convert Word documents into a Memo file, for these, which field type in SQL Server would work the best?
沿着这些相同的路线,我们也有时候将Word文档转换为Memo文件,对于这些文件,SQL Server中的哪种字段类型最好?
Thanks for your help.
谢谢你的帮助。
1 个解决方案
#1
3
It depends on the version of SQL Server you are using. 2005 and newer support VARCHAR(MAX), which can store strings up to 2GB. Short strings are stored efficiently (in the row) while larger strings are automatically stored in a blob database area, with only a pointer to the blob stored in the row. From a developer's perspective you don't need to worry about this complexity and use VARCHAR(MAX) if your data can exceed 8000 characters.
这取决于您使用的SQL Server版本。 2005和更新的支持VARCHAR(MAX),可以存储高达2GB的字符串。短字符串被有效地存储(在行中),而较大的字符串被自动存储在blob数据库区域中,只有指向存储在行中的blob的指针。从开发人员的角度来看,如果您的数据超过8000个字符,则无需担心这种复杂性并使用VARCHAR(MAX)。
As for your Word files, it depends if you want to store the actual file (in binary format) in the database or only the content. In the first case you could use VARBINARY(MAX) (or store the file on disk and only the path and other file meta data in SQL Server). If you want to store the actual content you will need to first convert to some suitable format (Rich Text, XML, etc.) and then store that in VARCHAR(MAX).
对于Word文件,它取决于您是要将实际文件(二进制格式)存储在数据库中还是仅存储内容。在第一种情况下,您可以使用VARBINARY(MAX)(或将文件存储在磁盘上,只存储SQL Server中的路径和其他文件元数据)。如果要存储实际内容,首先需要转换为某种合适的格式(Rich Text,XML等),然后将其存储在VARCHAR(MAX)中。
NOTE: use NVARCHAR instead of VARCHAR if your data contains unicode characters (rather than just ASCII)
注意:如果您的数据包含unicode字符(而不仅仅是ASCII),请使用NVARCHAR而不是VARCHAR
#1
3
It depends on the version of SQL Server you are using. 2005 and newer support VARCHAR(MAX), which can store strings up to 2GB. Short strings are stored efficiently (in the row) while larger strings are automatically stored in a blob database area, with only a pointer to the blob stored in the row. From a developer's perspective you don't need to worry about this complexity and use VARCHAR(MAX) if your data can exceed 8000 characters.
这取决于您使用的SQL Server版本。 2005和更新的支持VARCHAR(MAX),可以存储高达2GB的字符串。短字符串被有效地存储(在行中),而较大的字符串被自动存储在blob数据库区域中,只有指向存储在行中的blob的指针。从开发人员的角度来看,如果您的数据超过8000个字符,则无需担心这种复杂性并使用VARCHAR(MAX)。
As for your Word files, it depends if you want to store the actual file (in binary format) in the database or only the content. In the first case you could use VARBINARY(MAX) (or store the file on disk and only the path and other file meta data in SQL Server). If you want to store the actual content you will need to first convert to some suitable format (Rich Text, XML, etc.) and then store that in VARCHAR(MAX).
对于Word文件,它取决于您是要将实际文件(二进制格式)存储在数据库中还是仅存储内容。在第一种情况下,您可以使用VARBINARY(MAX)(或将文件存储在磁盘上,只存储SQL Server中的路径和其他文件元数据)。如果要存储实际内容,首先需要转换为某种合适的格式(Rich Text,XML等),然后将其存储在VARCHAR(MAX)中。
NOTE: use NVARCHAR instead of VARCHAR if your data contains unicode characters (rather than just ASCII)
注意:如果您的数据包含unicode字符(而不仅仅是ASCII),请使用NVARCHAR而不是VARCHAR