Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
SQL Server
Remote Connection using SQLCMD
Last Post 23 Feb 2010 02:37 AM by
Bobdee
. 1 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
Bobdee
Basic Member
Posts:130
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.
Bobdee
Basic Member
Posts:130
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.
Using PowerShell
--General PowerShell
--Active Directory
--Exchange Server
--SharePoint
--SQL Server
--System Center
--Non-Microsoft Products
--Books, Tools, and Videos
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
SQL Server
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2