header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Remote Connection using SQLCMD
Last Post 23 Feb 2010 02:37 AM by Bobdee. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
BobdeeUser is Offline
Basic Member
Basic Member
Posts:130
Avatar

--
23 Feb 2010 01:07 AM
    Hi,

    I'm using MS SQL cmdlets and am attempting to connect to a remote database.  However, I'm having a problem connecting using powershell :-
    $sqlconnect = 'sqlcmd -S DBServer\MyDB'
    Invoke-expression $sqlconnect

    Error is :-
    Sqlcmd: Error: Internal error at ReadTextLine (Reason: Unspecified error). At :line:1 char:7 + sqlcmd <<<< -S DBServer\MyDB

    If I run sqlcmd -S DBServer\MyDB in command prompt, I can connect no problem and do what ever I please to the data.

    Is there something I am missing when attempting to connect to the remote database?

    I do have another script running on a database that is local to my workstation, but that is SQLExpress rather than 2008 which we are running in our environment.

    Any help would be appreciated as this is doing my head in.

    Thanks.
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    23 Feb 2010 02:37 AM
    Found the solution with

    Invoke-SQLCMD -serverinstance DBserver\MyDB -query "xxxxxxx"

    pretty simple!!
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer