Hi,
I'm trying to create a table using powershell..following is my syntax
$conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=.\sqlexpress; Initial Catalog=testdata1; Integrated Security=SSPI")
$conn.Open()
$db= $srv.Databases.Item("TestData1")
$tb = new-object Microsoft.SqlServer.Management.Smo.Table($db, "companytable")
$col1 = new-object Microsoft.SqlServer.Management.Smo.Column($tb,"CompanyName", [Microsoft.SqlServer.Management.Smo.DataType]::NChar(50))
$tb.Columns.Add($col1)
$tb.Create()****
$cmd.ExecuteNonQuery()
$conn.Close()
My error is on the $tb.Create()
can someone tell me what am I missing here
Thanks