SQL SERVER DB Closed PHP Connection - sql-server

I am using php laravel to connect to a sql server db, but there is an issue sql server db "closed php connection". When I check requests in Profiler Trace, I have 2 requests: first one is from php audit login, then audit logout. The query doesn't complete, and I don't know why.
1) This error I get it from laravel:
SQLSTATE[08S01]: [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: An existing connection was forcibly closed by the remote host.
(SQL: select * from contact)
2) Image from SQL SERVER Profiler Trace

Related

SSIS OLEDB Connection Manager - Unable to connect to a database (No database names appear)

I am trying to create a connection manager in Microsoft SQL Server Data Tools for Visual Studio 2017 (SSDT) for an integration services project.
In the Connection Manager:
The Provider is set to: Native OLE DB\SQL Server Naive Client 11.0
The Server name is set to: the name of the local machine
Log on to the server is set to: Windows Authentication
Connect to a database is set to: Select or enter a database name. However no database names appear in the drop down box - the drop down box is blank. I am expecting the name of the database i am working on, including the master database etc to be present.
When I Test Connection, I get an error message which says:
'Test connection failed because of an error in initializing provider. Login timeout expired
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.
Named Pipes Provider: Could not open a connection to SQL Server [2]..'
I am using SQL Server 2017 and Microsoft SQL Server Management Studio 18.
Allow remote connections has been ticked in SSMS.
The only thing i can see is the SQL Server Agent and SQL Server Browser has stopped / is not running and the TCP/IP Protocols for SQLEXPRESS is set to disabled - I am unable to enable it without a further Access is denied (0x80070005) error.
I have tried to follow all of the guides but cannot progress. Could somebody please offer some further guidance?
I have resolved the issue. It was an extremely silly oversight! On installation, the server name in the Visual Studio 17 Connection Manager was listed as: Local MachineName only. In SQL Server, the Server Name was listed as: LocalMachineName\SQLEXPRESS. The Server Name in VS17 has to be exactly the same as SQL Server. As i said, this is a very silly oversight on my part but have documented for future reference.
SQL Server Configuration Manager ==> SQL Server Services(Left sidebar) ==> Right Click and Start all Stopped services

[Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: An existing connection was forcibly closed by the remote host

I am getting the following error in application log
[Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: An existing connection was forcibly closed by the remote host."
I am using Microsoft SQL Server 2014 and for datasource I am using ODBC Driver 17 for SQL Server. All connection checks seems to be working fine but the DB connection is getting closed intermittently. Any ideas or suggestions are appreciated.
I just ran into this issue myself and hopefully can shed some light. Driver Version: ODBC Driver 17 for SQL Server. 2017.174.02.01
Checking in the SQL Server logs, I found an error similar to this:
Log entry: Error: 17832, Severity: 20, State: 11.
The login packet used to open the connection is structurally invalid; the connection has been closed. Please contact the vendor of the client library. > [CLIENT: x.x.x.x]
I then found this doc on the MS Docs site which matched the 17832 event ID.
https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-17832-database-engine-error?view=sql-server-ver15
It describes that the MaxTokenSize setting on the SQL Server itself might be too small for this particular login token. You can set the MaxTokenSize to something greater to test and if that fixes it you will want to find out the actual token size and set it to only that big.

Restore big database from SQL server 2014 into SQL Server 2008

I just bought a new 2008 SQL server license and am now trying to move my 10gb database from 2014 express(12.0.5203) to 2008 (10.0.1600.22)
I have tried the "export DB to script" way, but the file is very big(20GB) and a lot of data is not getting imported because of several datatype convertion errors.
Currently I am trying to copy the data by scripts like
SELECT *
INTO database.dbo.table
FROM OPENQUERY([localhost\WAWI], ' SELECT *
FROM [localhost\WAWI].database.dbo.[table]')
While having created a connection in sys.servers
EXEC sp_addlinkedserver #server='WAWI'
EXEC sp_addlinkedsrvlogin 'localhost\WAWI', 'false', NULL, 'sa', 'password'
But while executing the import script I am not able to connect to the local 2014 server even so I have opened it in the object explorer in a query window opened by the remote 2008 server
I get the following error message
The OLE DB provider 'SQLNCLI10' for linked server 'WAWI' has the message 'Login timeout expired' return.
The OLE DB provider 'SQLNCLI10' for linked server 'WAWI' has the message ' network-related or instance-specific error when establishing a connection to SQL Server. The server could not be found, or it can not be accessed. Verify that the instance name is correct and that allows SQL Server remote connections. For more information in SQL Server Books Online.' return.
Message 53, level 16, State 1, line 20
Named pipes provider: it could be made cannot connect to SQL Server [53].

TSQL Having trouble adding a linked SQL Server 2008 R2 to SQL Server 2000

I'm having trouble trying to create a Linked Server to connect from a SQL Server 2008 R2 instance to a SQL Server 2000 instance using Windows Auth.
I can connect to SQL Server 2000 with SSMS with Windows Auth so network and user permissions should be OK.
Here's what I'm using so far
EXEC master.dbo.sp_addlinkedserver
#server = N'SalesLogix_db'
,#srvproduct=N'SalesLogix_db'
,#provider=N'SQLNCLI'
,#datasrc=N'xxx.xxx.xxx.xxx'
GO
--Windows Authentication
EXEC master.dbo.sp_addlinkedsrvlogin
#rmtsrvname=N'SalesLogix_db'
,#useself=N'True'
,#locallogin=NULL
,#rmtuser=NULL
,#rmtpassword=NULL
GO
EXEC master.dbo.sp_testlinkedserver SalesLogix_db;
And this is the error.
OLE DB provider "SQLNCLI10" for linked server "SalesLogix_db" returned message "Login timeout expired".
OLE DB provider "SQLNCLI10" for linked server "SalesLogix_db" 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 24
Named Pipes Provider: Could not open a connection to SQL Server [53].
Where am I going wrong?
Thanks in advance
+1, I got the exact same error message today in a similar setup (sql 2008 R2 server linking to a sql 2008 server). I had existing linked servers which worked fine, but all of a sudden stopped working (exact same error message as you).
I narrowed it down to a batch of recent Windows Security Updates (~14 of them) on the linked server (running windows 2008 R2). I ended up rolling back those updates which resolved the issue temporarily.
At this point, I'm trying to figure out which one of these updates (KBxxxx) is the exact culprit.
After much toing and froing I finally found the answer.
I was failing with double-hop authentication failure.
When I created the Linked Server using SSMS on the db server itself it worked.

Link Server between 2 servers doesn't work but works on all other servers

A little background on what has been going on. I have been in the process of upgrading our sql server from 2008 R2 to 2012. The way I have been doing this is by taking the server to upgrade, lets call it Server A. Then taking a server a new server, lets call it Server C.
Moving all databases from Server A to Server C.
Renaming Server C to Server A and Server A to Server C.
Completely blowing away the Server C (old Server A).
Installing windows 2012, and SQL Server 2012 on Server.
Rename both servers to their original name.
The network team actually installed Windows server, got it on the network, etc. I only installed SQL Server 2012. I have done this with 8 servers and have had no problems from them so far. Both servers are running SQL Server 11.0.3373 windows version 6.2 build(9200). I also am sysadmin on all sql servers, but not a domain admin.
The issue
I am trying to create a link server from Server A to Server B. I can create the link server without an error, but i get an error when i use it in a query.
More relevant information
The firewall is turned off on Server B on all these tests.
I am able to ping Server A from Server B and vice versa.
I did a tracert and it comes up with the correct server and ip address( from both servers)
When I create the link server with *Other data source*
“Microsoft OLE DB Provider for SQL Server” or “SQL Server native Client 11.0”
I am able to query the master database when I query a user created database I get this error:
Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "SQLNCLI11" for linked server "SERVER_B" does not contain the table ""UserDB"."dbo"."Table1"". The table either does not exist or the current user does not have permissions on that table.
SSMS
When I RDP into the Server A, run SSMS, try to connect to Server B I get this error:
"A transport-level error has occurred when receiving results from the server (Provider TCP Provider, error: 0- The specified network name is no longer available.) (Microsoft SQL Server Error: 64)"
RDP
When I try to RDP into Server B from Server A. I get an error that says "This computer can't connect to the remote computer. I also had a domain admin try and gets the same error.
Server B to A errors
I tried going the other way with it.
I RDP into Server B. In SSMS I try to connect to Server A. Below is the error i get.
A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.) (.Net SqlClient Data Provider)
Any help would be appreciated.

Resources