powershell

  • 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

  • thnx for your help..

    I solved it

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply