C# SqlServer Smo DropPeriodForSystemTime不工作
我有以下代码:C# SqlServer Smo DropPeriodForSystemTime不工作,c#,sql-server,smo,C#,Sql Server,Smo,我有以下代码: public IEnumerable<string> GetScript() { //This is what we will return IEnumerable<string> scriptStrings = null; SqlConnection conn = new SqlConnection(ConnectionString);
public IEnumerable<string> GetScript()
{
//This is what we will return
IEnumerable<string> scriptStrings = null;
SqlConnection conn = new SqlConnection(ConnectionString);
var server = new Server(new ServerConnection(conn));
this.Database = server.Databases[conn.Database];
this.CopyAllObjects = false;
this.CopyAllTables = false;
//We only want to copy tables in a specific schema.
List<Table> tablesToCopy = new List<Table>();
foreach (Table t in this.Database.Tables)
{
var isInWhitelist = Whitelist
.Any(o => o.Name.Equals(t.Name, StringComparison.InvariantCultureIgnoreCase)
&& o.Schema.Equals(t.Schema, StringComparison.InvariantCultureIgnoreCase));
if (isInWhitelist)
{
e
foreach (Column col in t.Columns)
{
col.Identity = false;
if (!col.InPrimaryKey)
col.Nullable = true;
col.GeneratedAlwaysType = GeneratedAlwaysType.None;
}
t.IsSystemVersioned = false;
t.HistoryTableName = string.Empty;
t.HistoryTableSchema = string.Empty;
tablesToCopy.Add(t);
}
}
//Add specifically the tables we want which are from the schema we want
this.ObjectList.AddRange(tablesToCopy);
this.Options.NoCollation = true;
this.Options.WithDependencies = false;
this.Options.DriPrimaryKey = true;
try
{
scriptStrings = this.ScriptTransfer().Cast<string>();
}
catch (Exception ex)
{
Console.WriteLine("We got an exception.");
throw;
}
return scriptStrings;
}
我不明白为什么
系统时间的周期([SysStartTime],[SysEndTime])
仍在生成的脚本中。即使打过电话
t、 DropPeriodForSystemTime()
一个超过250列的表看起来像是一个受到非规范化数据严重影响的表(或数据库)。
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[Deal](
[Id] [bigint] NOT NULL,
SysStartTime,
SysEndTime
--fields removed
CONSTRAINT [PK_Deals] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
PERIOD FOR SYSTEM_TIME ([SysStartTime], [SysEndTime])
) ON [PRIMARY]