今天创建SQL2008快照时,快照代理报错: 错误消息:Source: Microsoft.SqlServer.SmoTarget Site: System.Collections.Generic.IEnumerable`1[System.String] ScriptWithList(Microsoft.SqlServer.Management.Smo.DependencyCollection, Microsoft.SqlServer.Management.Smo.SqlSmoObject[])Message: 脚本 对于 表“dbo.patientExemItem_map_his=”失败。 Stack: 在 Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects) 在 Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(SqlSmoObject[] objects) 在 Microsoft.SqlServer.Replication.Snapshot.TransSmoScriptingManager.GenerateLogBasedArticleSchScript(Scripter scripter, BaseArticleWrapper articleWrapper, Table smoTable) 在 Microsoft.SqlServer.Replication.Snapshot.TransSmoScriptingManager.GenerateLogBasedArticleScripts(ArticleScriptingBundle articleScriptingBundle) 在 Microsoft.SqlServer.Replication.Snapshot.TransSmoScriptingManager.GenerateArticleScripts(ArticleScriptingBundle articleScriptingBundle) 在 Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.GenerateObjectScripts(ArticleScriptingBundle articleScriptingBundle) 在 Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.DoScripting() 在 Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.DoScripting() 在 Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.GenerateSnapshot() 在 Microsoft.SqlServer.Replication.SnapshotGenerationAgent.InternalRun() 在 Microsoft.SqlServer.Replication.AgentCore.Run() (源: Microsoft.SqlServer.Smo,错误号: 0)获取帮助: http://help/0Source: Microsoft.SqlServer.SmoTarget Site: Void CheckSupportedType(Microsoft.SqlServer.Management.Smo.ScriptingOptions)Message: 对象 patientExemItem_map_his 中的列 createdate 包含类型 Date,此类型不受目标服务器版本 SQL Server 2000 支持。Stack: 在 Microsoft.SqlServer.Management.Smo.Column.CheckSupportedType(ScriptingOptions options) 在 Microsoft.SqlServer.Management.Smo.Column.VersionValidate(ScriptingOptions so) 在 Microsoft.SqlServer.Management.Smo.Column.ScriptDdlCreateImpl(StringBuilder sb, ScriptingOptions so) 在 Microsoft.SqlServer.Management.Smo.Column.ScriptDdl(StringCollection queries, ScriptingOptions so) 在 Microsoft.SqlServer.Management.Smo.Table.ScriptTableInternal(ScriptingOptions so, StringBuilder sb, ColumnCollection columns, IndexCollection indexes) 在 Microsoft.SqlServer.Management.Smo.Table.GetTableCreationScript(ScriptingOptions so, StringBuilder sb) 在 Microsoft.SqlServer.Management.Smo.Table.ScriptCreate(StringCollection queries, ScriptingOptions so) 在 Microsoft.SqlServer.Management.Smo.SqlSmoObject.ScriptCreateInternal(StringCollection query, ScriptingOptions so) 在 Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithListWorker(DependencyCollection depList, SqlSmoObject[] objects) 在 Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects) (源: Microsoft.SqlServer.Smo,错误号: 0)获取帮助: http://help/0 英文版本的类似报错: Message: Script failed for Table 'dbo.patientExemItem_map_his'. Source: Microsoft.SqlServer.SmoTarget Site: System.Collections.Generic.IEnumerable`1[System.String] ScriptWithList(Microsoft.SqlServer.Management.Smo.DependencyCollection, Microsoft.SqlServer.Management.Smo.SqlSmoObject[])Message: Script failed for Table 'dbo.patientExemItem_map_his'. Stack: at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects)at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(SqlSmoObject[] objects)at Microsoft.SqlServer.Replication.Snapshot.TransSmoScriptingManager.GenerateLogBasedArticleSchScript(Scripter scripter, BaseArticleWrapper articleWrapper, Table smoTable)at Microsoft.SqlServer.Replication.Snapshot.TransSmoScriptingManager.GenerateLogBasedArticleScripts(ArticleScriptingBundle articleScriptingBundle)at Microsoft.SqlServer.Replication.Snapshot.TransSmoScriptingManager.GenerateArticleScripts(ArticleScriptingBundle articleScriptingBundle)at Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.GenerateObjectScripts(ArticleScriptingBundle articleScriptingBundle)at Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.DoScripting()at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.DoScripting()at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.GenerateSnapshot()at Microsoft.SqlServer.Replication.SnapshotGenerationAgent.InternalRun()at Microsoft.SqlServer.Replication.AgentCore.Run() (Source: Microsoft.SqlServer.Smo, Error number: 0)Get help: http://help/0Source: Microsoft.SqlServer.SmoTarget Site: Void CheckSupportedType(Microsoft.SqlServer.Management.Smo.ScriptingOptions)Message: Column definition in object patientExemItem_map_his contains type date, which is not supported in the target server version, SQL Server 2000.Stack: at Microsoft.SqlServer.Management.Smo.Column.CheckSupportedType(ScriptingOptions options)at Microsoft.SqlServer.Management.Smo.Column.VersionValidate(ScriptingOptions so)at Microsoft.SqlServer.Management.Smo.Column.ScriptDdlCreateImpl(StringBuilder sb, ScriptingOptions so)at Microsoft.SqlServer.Management.Smo.Column.ScriptDdl(StringCollection queries, ScriptingOptions so)at Microsoft.SqlServer.Management.Smo.Table.ScriptTableInternal(ScriptingOptions so, StringBuilder sb, ColumnCollection columns, IndexCollection indexes)at Microsoft.SqlServer.Management.Smo.Table.GetTableCreationScript(ScriptingOptions so, StringBuilder sb)at Microsoft.SqlServer.Management.Smo.Table.ScriptCreate(StringCollection queries, ScriptingOptions so)at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ScriptCreateInternal(StringCollection query, ScriptingOptions so)at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithListWorker(DependencyCollection depList, SqlSmoObject[] objects)at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects) (Source: Microsoft.SqlServer.Smo, Error number: 0)Get help: http://help/0 原因是此前数据库的版本是SQL2000,迁移到2008上后没有修改数据库的兼容级别到100。 在发布数据库上执行如下代码,修改数据库的兼容级别到100,修改后问题解决: ALTER DATABASE [DataBase SET COMPATIBILITY_LEVEL = 100
|