header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

Remote Connection using SQLCMD
Last Post 23 Feb 2010 11:37 AM by bobdee1980. 1 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
bobdee1980User is Offline
New Member
New Member
Posts:57
Avatar

--
23 Feb 2010 10: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.
bobdee1980User is Offline
New Member
New Member
Posts:57
Avatar

--
23 Feb 2010 11: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.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer