在多執行續環境中,使用SMO的 Scriptable.Script 呼叫會不定期發生SqlSmoObject.GetQueryTypeKeyFields錯誤
Microsoft.SqlServer.Management.Smo.FailedOperationException: Script failed for Table 'dbo.XXXX'. ---> Microsoft.SqlServer.Management.Smo.FailedOperationException: Script failed for Table 'dbo.XXXX'. ---> System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetQueryTypeKeyFields(Type t)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetQueryTypeKeyFieldsCount(Type t)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.InitObjectsFromEnumResultsRec(SqlSmoObject currentSmoObject, XPathExpression levelFilter, Int32 filterIdx, IDataReader reader, Int32 columnIdx, Object[] parentRow, Boolean forScripting, List`1 urnList, Int32 startLeafIdx)
…………………………
解決方法:
SQL Server 2008 請上sp2
>> can use multiple SMO.Server with different connections in multithreaded application now. But if one uses multiple SMO.Server sharing same conenction it will result in datareader exception of connection already in use.
SQL Server 2008 R2 請上sp1
留言列表