一、首先打开数据库,我这里以SQL Server 2012数据库为例。
1.选择工具—>选项 ,如图1
图 1
2. 选择表设计器和数据库设计器—>阻止保存要求重新创建表的更改(S)把前面checkbox勾选去掉,然后点击确定,如图2
图 2
二、打开数据库名对应的表,找到要修改的属性,这里相信只要大家学过基本的SQL知识都会改的。具体如图3
把200改为2000 保存下。改的字段为abc_value。
三、通过SQL根据PhysicalName 和 AttributeId 在Attribute表确定其是abc_value这个值。然后在Update其MaxLength的长度为2000,具体代码如下:
SELECT TOP 100 [AttributeId]
,[AttributeTypeId]
,[Name]
,[PhysicalName]
,[Length]
,[IsNullable]
,[XmlAbbreviation]
,[EntityId]
,[DefaultValue]
,[ColumnNumber]
,[ValidForUpdateAPI]
,[LogicalName]
,[ValidForReadAPI]
,[ValidForCreateAPI]
,[VisibleToPlatform]
,[IsPKAttribute]
,[IsCustomField]
,[IsLogical]
,[DisplayMask]
,[AttributeOf]
,[ReferencedEntityObjectTypeCode]
,[AggregateOf]
,[IsSortAttribute]
,[PrecisionValue]
,[PrecisionSource]
,[IsIdentity]
,[IsReplicated]
,[VersionNumber]
,[YomiOf]
,[AttributeRowId]
,[AppDefaultValue]
,[AttributeLogicalTypeId]
,[Locked]
,[AttributeImeModeId]
,[AttributeRequiredLevelId]
,[MaxLength]
,[MinValue]
,[MaxValue]
,[Accuracy]
,[AccuracySource]
,[LookupStyle]
,[LookupBrowse]
,[ImeMode]
,[HasMultipleLabels]
,[IsRowGuidAttribute]
,[IsBaseCurrency]
,[CalculationOf]
,[IsAuditEnabled]
,[UpgradeDefaultValue]
,[OptionSetId]
,[SolutionId]
,[SupportingSolutionId]
,[ComponentState]
,[OverwriteTime]
,[LinkedAttributeId]
,[InheritsFrom]
,[IsStoredOnPrimaryTable]
,[IsInheritanceTypeAttribute]
,[TableColumnName]
,[IsUnmanagedAttribute]
,[IsOneWayBooleanAttribute]
,[IsCustomizable]
,[IsRenameable]
,[CanModifySearchSettings]
,[CanModifyRequirementLevelSettings]
,[CanBeSecuredForCreate]
,[CanBeSecuredForRead]
,[CanBeSecuredForUpdate]
,[IsSecured]
,[DeprecatedVersion]
,[IsManaged]
,[ManagedPropertyLogicalName]
,[ManagedPropertyParentComponentType]
,[ManagedPropertyParentAttributeName]
,[CanModifyAdditionalSettings]
,[ValuesFromRelationshipAttribute]
,[CanModifyAuditSettings]
FROM [组织名称_MSCRM].[MetadataSchema].[Attribute]
WHERE PhysicalName = 'abc_value' AND AttributeId='F9EE8BA9-69F4-487A-A335-D565FBE9D0FA'
SQL1
SQL1你可以先去掉后面的AttributeId属性,试着查看。
Update Attribute
SET MaxLength = 2000
WHERE PhysicalName = 'abc_value' AND AttributeId='F9EE8BA9-69F4-487A-A335-D565FBE9D0FA'
SQL2
SQL2就是执行修改的方法。
说明:在数据库里面修改实体字段的长度的时候,二和三步骤都不能少。