How to access SQL Server 2005 FROM a guest XP OS running in Virtual PC - sql-server-2005

I am running as my Host OS - Win 7 x64 and running an instance of SQL Server 2005 (developer, x64). I am also running an instance of Virtual PC XP and am trying to connect to the Host OS Sql Instance without alot of luck.
I can ping the Host from the Guest OS and vice versa.
The Virtual PC Guest is not using the NAT network adapter, but the physical adapter of the machine.
I ran SQL Server Surface Area Configuration tool on the host and made sure both local and remote connections are allowed for both TCP/IP and Named pipes.
I installed the SQL Server 2005 Native client on the Guest XP OS as well as SQLCMD.
When I issue: "SQLCMD -L" I see:
Servers:
ROBSWIN7BOX
However when I try "SQLCMD -S ROBSWIN7BOX", I get:
HResult 0x52E, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [1326].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connection
s..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.
I've also tried various SQLCMD -S .. -U sa .. -P and SQLCMD -S ... -E (SQL Server is configured for Mixed mode authentication).
Any ideas? What am I overlooking?
THanks!
Rob

Error 0x52e: (Win32) 0x52e (1326) - Logon failure: unknown user name or bad password.
You need Win auth to open the named pipe. Make sure SQL port is open by firewall on host and force tcp in your connection: SQLCDM -S tcp:ROBSWIN7BOX -U user -P pwd

Related

How to connect to remote SQL Server from WSL2 using ODBC?

I want to connect to a remote SQL Server from WSL2, but I keep getting errors for some reason. I tried connecting using my Windows Host machine without any problem.
~/.odbc.ini
[MSSQLTest]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.9.so.1.1
server=tcp:server,port
Database=Databasename
Trusted_Connection=yes
TrustServerCertificate=yes
uid=username#domain.com
pwd=password
odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/test/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Errors
test#Desktop:/mnt/c/Users/test$ isql -v mssqltest
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Cannot generate SSPI context
I tried several different changes in the DSN, but none worked. The only thing that changed was the error messages. Then I tried installing mssql-tools to use sqlcmd, but I got similar errors.
Errors
test#DESKTOP:/mnt/c/Users/test$ sqlcmd -S server -U domain\\username -P password -G
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish the connection.
I have no idea what the error above means.
test#DESKTOP:/mnt/c/Users/test$ sqlcmd -S server#example.com -U domain\username -P password -G
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
I get a similar error. If I change something in the DSN, I get an error stating No kerberos credentials available (default cache: FIEL:/tmp/krb5cc_1000). Cannot generate SSPI context.
I looked up and tried many different solutions suggested on SO and other sites, but I can't seem to get it working. I can, however, ping the server.
Why is it doing this? Why does my connection work from my Windows Host machine but not WSL? What am I missing?
I don't think there's anything wrong with your setup. You might want to check if your admin allows SQL Authentication. Then use the sqlcmd to check if it works for you. You may be able to figure out the solution then.
sqlcmd -SXX.XX.XX.XXX -U username -P password -Q "select top 5 * from your_table"

Create Node.js apps using SQL Server on macOS

I am installing SQLCMD. My Command:
sqlcmd -S 127.0.0.1 -U sa -P your_password
But there is an error was showing...
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2726.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specifc 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.
Can anyone help me out??
You need to specify the port on your server in your sqlcmd.
-S [protocol:]server[instance_name][,port]
https://learn.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15

Is it possible using Pymssql to access SQL Server 2012 remotely, with domain (windows) user account

I could not access SQL Server 2012 remotely using windows user account, even though its possible to access SQL Server after login to Windows OS with the same credentials.
Is there any way to achieve that?
Due to Security (OS Hardening) reason's SQL Server users are not supported
Trying to Access SQL 2012 remotely from CentOS
telnet host 1433 #Works fine
TCP enabled in SQL Configuration manager.
pymssql version - 2.1.0
pymssql.connect('192.168.1.7', 'mydomain\\dba', 'password', 'testdb')
I'm getting below error
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pymssql.pyx", line 599, in pymssql.connect (pymssql.c:9315) pymssql.OperationalError: (20002, 'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed\n')
FreeTDS configuration
tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
Yes, this can be done during the connection:
pymssql.connect(
server='192.168.1.7:1433',
user='mydomain\\dba',
password='password',
database='testdb',
tds_version='7.2'
)
Please note you'll have to be sure you can connect to the server SQL Server is running on from the machine you're running pymssql on. If things are locked down, you made need firewall modifications to be made. You can test to see if you can connect to your SQL Server server with telnet: telnet your_host 1433 to see if it connects, or just hangs.

Error shutting down Windows XP machine with RPC

I have an Ubuntu server on the same LAN with a Windows XP Professional machine.
I'm trying to issue the following command from the server to shutdown
the machine:
net rpc shutdown -I 192.168.X.X -U <username>%<password> -r -f
but I get the error :
Could not connect to server 192.168.X.X
The user name or password was not correct.
Connection failed: NT_STATUS_LOGON_FAILURE
The credentials are correct, checked it several times. What can be the problem?
I'd appreciate any help.
Perhaps <username> must be prefixed with the windows domain or workstation name (i.e. the scope within which the username is defined):
domain\username

Could not connect to SQL Server using osql

I have a script that connects to SQL Server 2005 default instance. But I'm and being connected and instead got the following message
[SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [53].
[SQL Native Client]Login timeout expired
[SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.
The script's content is:
osql -E -S <servername> -i D:\scripts\script1.sql -o D:\scripts\script1.txt
I looked at the network connection from SQL Server Configuration Manager. The TCP/IP is enabled but the Named Pipes is disabled.
My question is what could be the possible cause and solution for this error?
try osql -E -S(local) or osql -E -S. I have not figured out why sometimes it does work, and other times it does not.