Condividi tramite


Metodo AlterWithNoCheck

Aggiorna tutte le modifiche apportate alle proprietà dell'oggetto Table nell'istanza di SQL Server senza prima controllare i valori delle proprietà. 

Spazio dei nomi  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

Sintassi

'Dichiarazione
Public Sub AlterWithNoCheck
'Utilizzo
Dim instance As Table

instance.AlterWithNoCheck()
public void AlterWithNoCheck()
public:
void AlterWithNoCheck()
member AlterWithNoCheck : unit -> unit 
public function AlterWithNoCheck()

Osservazioni

The AlterWithNoCheck method updates any changes that have been made to the Table object's properties since the Table object was created or since the last Alter statement. The modifications are combined and sent to the instance of SQL Server in a single network trip to the instance of SQL Server.

Esempi

The following code example shows how to create a new table, and then update it by using the AlterWithNoCheck method.

C#

Server srv = new Server("(local)");
Database db = srv.Databases["AdventureWorks2008R2"];

Table tb = new Table(db, "Test Table");
Column col1 = new Column(tb, "Name", DataType.NChar(50));
Column col2 = new Column(tb, "ID", DataType.Int);

tb.Columns.Add(col1); 
tb.Columns.Add(col2); 
tb.Create();

Column col3 = new Column(tb, "Date", DataType.DateTime);
tb.Columns.Add(col3);
tb.AlterWithNoCheck();

Powershell

#Connect to the local server and get the AdventureWorks2008R2 database
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2008R2")

#Create the Table
$tb = new-object Microsoft.SqlServer.Management.Smo.Table($db, "Tester Table")
$col1 = new-object Microsoft.SqlServer.Management.Smo.Column($tb, "Name", [Microsoft.SqlServer.Management.Smo.DataType]::NChar(50))
$col2 = new-object Microsoft.SqlServer.Management.Smo.Column($tb, "ID", [Microsoft.SqlServer.Management.Smo.DataType]::Int)
$tb.Columns.Add($col1)
$tb.Columns.Add($col2)
$tb.Create()

#Add a new column and update the table
$col3 = new-object Microsoft.SqlServer.Management.Smo.Column($tb, "Date", [Microsoft.SqlServer.Management.Smo.DataType]::DateTime)
$tb.Columns.Add($col3)
#$tb.AlterWithNoCheck()
Write-Host $tb.Columns
$tb.Drop()