Register
: :
Login
Home
Forums
Blogs
Podcast
Directories
Scripts
Downloads
Community
User Group Support
Learning Resources
We have a new sponsor! Introducting
Pragma Systems
. See the home page for details.
Unanswered
Active Topics
Forums
Search
Members
Forums
>
Using PowerShell
>
SQL Server
Remote Connection using SQLCMD
Last Post 23 Feb 2010 11:37 AM by
bobdee1980
. 1 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
bobdee1980
New Member
Posts:57
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.
bobdee1980
New Member
Posts:57
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.
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--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
Forums
>
Using PowerShell
>
SQL Server
Active Forums 4.1
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008