Alternative to invoke-sqlcmd cmdlet - SMO

  • Hi Team,

    I am trying to retrieve sql data using powershell code - invoke-sqlcmd. Invoke-sqlcmd is failing with not recongnized error , as there are no client components installed on the machine where powershell code is running.

    Please suggest alternative to invoke-sqlcmd which can retrieve data to powershell arrays.

    Thanks.

  • Remote call to PowerShell hosted on a box with the necessary components installed.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Install the necessary components - they are provided as separate downloads.  If you don't want to do that - then you need to implement the same ADO.NET code that you would use for a C# or VB.Net application.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Thanks for the comments.

    with .net connections can we achieve everything as like with invoke-sqlcmd ?  I want to import the SQL Data into an array  and insert the same back into SQL table after new database restore activity.

    Thanks.

  • chinna.sp3025 - Wednesday, March 29, 2017 3:58 AM

    ...with .net connections can we achieve everything as like with invoke-sqlcmd ?...

    Yes. Pretty much. Not sure that is the ideal way though. It depends what you are trying to do under what circumstances.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

Viewing 5 posts - 1 through 4 (of 4 total)

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