Execute sql script using sqlcmd.exe - sql-server-2008

C:\>sqlcmd -S(local) -U(sa) -P(password) -i F:\sql.sql
HResult 0x3, Level 16, State 1 Named Pipes Provider: Could not open a
connection to SQL Server [3]. Sqlcmd: Error: Microsoft SQL Server
Native Client 10.0 : A network-related or in stance-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 i f SQL
Server is configured to allow remote connections. For more information
see SQL Server Books Online.. Sqlcmd: Error: Microsoft SQL Server
Native Client 10.0 : Login timeout expired.
How I resolve this problem

Execute this query on this folder window->system32, because every sql command executes in this folder..
C:\Windows\system32>sqlcmd -S(local) -U(sa) -P(password) -i F:\sql.sql

Related

SQL Server Mgmt Studio 2014 ; Error 40

I just installed MS SQL SERVER MANAGEMENT STUDIO 2014 , but when I open it I have to add a server name to connect it but it is showing me following error when I enter server name.
TITLE: Connect to Server
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2) The system cannot find the file specified
I don't know what to do now, help me out please.
Thanks
Error
Here's mine, if it helps. See if you should have more to it, like SQLEXPRESSPC in my case.
You need to provide an instance name.
Instance Name has been provided during the installation process of SQL Server.
Inside the Server name combobox, you should type something like : .\SQLEXPRESS or .\MSSQLEXPRESS depending on your version of SQLServer.
The .\ refer to your local machine.

Microsoft sql server 2008 Error: 53?

I just installed sql server 2008 . When I tried to connect it . It was showing this message :
*TITLE: Connect to Server
Cannot connect to SQLServer.
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=53&LinkId=20476
I visited the link but I didn't find any solution .
I think something went wrong when you install it because my configuration manager show like this check snapshot here http://prntscr.com/6fdvog

Error while executing the Windows command through a batch file.

I have remote login permission to this server and this server is ping-able from my system but still I am getting the following error message. Can any one tell me why I am getting this.
Thanks.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : SQL Server Network Inte
rfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. .
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 in
stance-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 i
f SQL Server is configured to allow remote connections. For more information see
SQL Server Books Online..

Can't connect to server on SQL Server Management Studio 2008

When I open the Management Studio and try to connect using the [PCNAME]/SQLEXPRESS it shows this error:
"Cannot connect to [PCNAME]\SQLEXPRESS"
ADDITIONAL INFORMATION:
Error Message:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found
or was not accessible. Verify that the instance name is correct and
that SQL Server is configured to allow remote connections. (provider:
SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified) (Microsoft SQL Server, Error: -1)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476"
I've also tried "localhost", "local" and "." in the place for [PCNAME] but to no avail.
Make sure SQL Server (SQL Express) service is running.
in powershell prompt type:
Get-Service -Name 'MSSQL$SQLEXPRESS'
service "status" property should be reported as "Running"
If it is not, type (you need to be in elevated prompt, i.e. "Run as Administrator"):
Start-Service -Name 'MSSQL$SQLEXPRESS'
OR
click start > type cmd and type
sc query MSSQL$SQLEXPRESS
State should be reported as "Running"
If it is not, type (you need to be in elevated prompt, i.e. "Run as Administrator"):
sc start MSSQL$SQLEXPRESS
If you get an error that the service cannot be found:
Open SQL server Configuration Manager and make sure you have SQL server express installed:
open you sqlserver config manager enable your tcpip both sqlserver and express and also under client protocol anf try to turnoff your firewall this will allow remote connection
first check sql server is running or not if not start it from services.msc
then
add .\SQLEXPRESS it will resolve problem

Linked Server Connection Error

I created a linked server to my machine to query from other server using this script.
EXEC sp_addlinkedserver
#server = N'serverdatabase\vtidbserver',
#provider = N'SQLOLEDB',
#datasrc = N'VTI_FIS',
#srvproduct=''
EXEC sp_addlinkedsrvlogin
#rmtsrvname=N'serverdatabase\vtidbserver',
#useself=N'False',
#locallogin=NULL,
#rmtuser=N'vtidbadmin',
#rmtpassword='vallacar#654321'
now the script successfully execute but when it try to query, this is the error message that i got:
OLE DB provider "SQLNCLI10" for linked server "serverdatabase\vtidbserver" returned message "Login timeout expired".
OLE DB provider "SQLNCLI10" for linked server "serverdatabase\vtidbserver" returned message "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.".
Msg 53, Level 16, State 1, Line 0
Named Pipes Provider: Could not open a connection to SQL Server [53].
But when using management studio i can connect to the server successfully.
Need to help this problem, TIA
I suppose it is another MS SQL server.
If it is, you don't have to use provider, only have to specify product.
exec master.dbo.sp_addlinkedserver #server = N'TEST', #srvproduct=N'SQL Server'
Hope that helps.