-
February 7th, 2021, 08:21 AM
#1
SQLCMD failure
I am trying to attach an ms sql database. And I am trying to use sqlcmd utillity. But anytime I try this, I got:
Code:
SQLCMD
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
of course, I have tried to find the server name and instance, with:
and the answer was:
Code:
Servers:
;UID:Login ID=?;PWD:Password=?;Trusted_Connection:Use Integrated Security=?;*APP:AppName=?;*WSID:WorkStation ID=?;
How can I find the server name and the instance name then ?
-
February 7th, 2021, 12:53 PM
#2
Re: SQLCMD failure
Victor Nijegorodov
-
February 7th, 2021, 01:02 PM
#3
Re: SQLCMD failure
Are the named pipes protocol enabled on sql server? They aren't by default. Search google for "sql configuration manager"
-
February 7th, 2021, 01:50 PM
#4
Re: SQLCMD failure
Originally Posted by Arjay
Are the named pipes protocol enabled on sql server? They aren't by default. Search google for "sql configuration manager"
Yes, they are enabled.
-
February 7th, 2021, 04:34 PM
#5
Re: SQLCMD failure
Originally Posted by mesajflaviu
Yes, they are enabled.
Are you able to connect with SSMS?
Btw, I've used SQLCMD within PowerShell for years, but recently ran into a issue where it just would not connect to a specific server. Never could figure out the issue.
Rather than calling SQLCMD with PowerShell, I changed the code to use the SqlServer PowerShell module.
-
February 9th, 2021, 12:20 PM
#6
Re: SQLCMD failure
In the ending is solved. Thank you all of you !
-
February 9th, 2021, 01:00 PM
#7
Re: SQLCMD failure
Originally Posted by mesajflaviu
In the ending is solved. Thank you all of you !
Could you share your solution?
Victor Nijegorodov
-
February 11th, 2021, 11:49 AM
#8
Re: SQLCMD failure
I succeeded with following commands:
Code:
SQLCMD.EXE -S DESKTOP-YYYYYY\SQLEXPRESS
CREATE DATABASE mydataabse ON (FILENAME = 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\mydatabase.mdf'), (FILENAME = 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\mydatabase_Log.ldf') FOR ATTACH;
GO
after I enabled Name Pipes from Sql Server Configuration Manager.
Thank you for your support.
Last edited by mesajflaviu; February 15th, 2021 at 05:18 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|