sqlcmd not connecting to Azure database - azure

I am trying to use the command below to access my database within Azure
sqlcmd -s tcp:DBNAME HERE.database.windows.net -U USERNAME -P PASSWORD
I get the error
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Named Pipes
Provider: Could not open a connection to SQL Server [2]. . Sqlcmd:
Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout
expired. Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : 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..
Has anyone ever had this? I have downloaded the latest version of sqlcmd
I need to get a lot of data into my Azure database, but I am running out of options as the Import Data option in management studio cant cope. This was the first method I tried. After processing 70000 of 250000 rows it just goes to stopped with no error message, thats what then led me to try with BCP SQLCMD
Paul

Your command is incorrect. The 'S' should be capitalized and you should provide the server name, not the database name.
sqlcmd -S tcp:myServer.database.windows.net -d database -U username -P password
See the documentation page for the complete syntax of sqlcmd.

Please make a ping to the name of your Azure SQL Database server as shown below:
C:\> ping myserver.database.windows.net
The ping command should fail but it should return the current IP of your SQL Azure Database server. If it fails to return that IP, then you cannot access to Azure server due to a DNS resolution problem.
If the ping command returned the IP address successful, then try to telnet your SQL Azure Database server as shown below.
C:\> telnet myserver.database.windows.net 1433
If the telnet command fails make sure your computer firewall or network hardware is allowing traffic to the IP returned on the previous step and make sure TCP port 1433 is open. If your are trying this from a corporate network, please contact your network administrator with this requirements.
Please note that you may need to enable the telnet command via Control Panel -> Program and Features -> Turn on/off features.

I just want to point out that BCP and sqlcmd are two different tools.
BCP is the bulk copy command. The later is the command line tool for querying.
If you are getting a named pipes issue, you might not have the client and/or server libraries configured.
Please go to SQL Server Configuration manager to check the settings.
By default, Azure SQL database is using TCP and you do not need to tell it on the command line.
In the image above, I am connecting to a Azure SQL database using the correct switches from books on line. Querying the sys.tables catalog returns the information that I expect. Two tables with different names. One duplicated named table under different schemas.
The BCP command will work the same way. You might even want to try a format file.
I want to clarify your statement that importing is taking a long time. Please remember that Azure SQL database is platform as a service. The database tiers are set at predetermined DTU's. That means stuffing the server with a lot of data will result in a throttled server at MAX DTU's.
I would look at the portal and see if that is your situation.
In short, sqlcmd, bcp and the import/export wizard are perfect tools for data loads a lot larger than the numbers you are talking about. Just remember, syntax is key to any successful program!

Related

Not able to fetch data or queue data from FTP server in Azure cloud nifi server?

I am using FTP server which is working in local and able to fetch data from FTP server, but in the Azure cloud nifi server same FTP server is not fetching a single record from the particular FTP server. I am using ListFTP associated with FetchFTP nifi processor and used the same configuration whatever I used in local for ListFTP and FetchFTP nifi processors.
Can someone please suggest what is happening here. I checked firewall and even I disabled the firewall. That FTP server is running on Active connection mode. I tried but I'm not able to figure out the exact reason.
I am attaching the screenshots of my FTP processors configuration. One very important thing while using GetFTP server it is not fetching a single data after running hours of hours and even not a single exception or error. But with ListFTP and FetchFTP server it is showing exception after some 15 minutes interval that is "Failed to perform listing on remote host due to java.net.SocketException"
I think once you go through your conf/nifi.properties file and check whether keystore certificate is enabled or disabled and if it is disabled then do it enable.
Here you can check nifi configuration documentation.

SharePoint 2010-"Cannot connect to the configuration database"

I have TFS 2012 which integrated with SharePoint service, recently I duplicated the same machine for testing, and modified some parameters on the testing machine to avoid conflict due to they are in the same networking. They works well.
Today the production server's SharePoint site prompt "Cannot connect to the configuration database", but team foundation service works well, I doubt that something in the testing server cause this, and I shutdown testing server, the issue still exists.
Before I have experience for this issue, most of them are related with SQL server instance configuration like this "https://mikessharepoint.wordpress.com/2011/11/22/cannot-connect-to-the-configuration-database-error-of-central-administration/" or some authentications issue in the IIS application pool.
and here is the error event from event viewer:
"
Unknown SQL Exception 53 occurred. Additional error information from SQL Server is included below.
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)
"
I doubt that something (probably SQL server instance name) on production server change to testing servers by some action, but I don't know where and how.
And I doubt that the new server cause the error, the reason is I find something incorrect in wss_config database of production server, the "ServerName" filed in table TimerJobHistory, some value are new server, some value are old server. But even I update all the value to old server and restarted the production server, it does not work.
I check all things I can googled, but nothing works, is there anybody could provide any help on this, appreciate for any kindly help.
Finally, I find the root reason, there is a table named "Objects" in the "Wss_config" DB, I find the new testing server name in "Name" filed, so I update the value to old server name-->Restarted IIS and SharePoint service (not sure if required)-->Bingo!
But I still don't know why the new server cause this error, so I have not power on the new server for now. Will update if any new detection.
Thanks all for your kindly help.

Excel VBA Userform to SQLOLEDB Connection works Locally but not remotely - Run-time error '-2147467259 (80004005)': [DBNETLIB]

It's been a week of research now and I am still unable to fix this problem.
I have created an Excel VBA User form that inserts data into an SQLOLEDB Connection (SQLEXPRESS 2017) when a CommandButton (Called "Save") is clicked. Locally (localhost) it works like a charm. All of the data from the columns gets inserted into the SQL DB Table successfully. No errors whatsoever.
However, when any client attempts to perform the same action I get the Run-time error '-2147467259 (80004005)': [DBNETLIB](ConnectionOpen (connect()).]SQL Server does not exist or access denied.
This is what I have tried so far:
I have created a Login for the client in my SQL Server Management Studio.
I have granted Insert permissions to the client to the dbo.Table.
I have made sure "Allow Remote Connections to this Server" is checked in Connections in my server properties in SQL Server Management Studio.
I have added Inbound & Outbound Rules in my Windows Firewall to Open port 1433 in my Computer which is where the Server has been installed.
I have added Inbound & Outbound Rules in Windows Firewall to Open port 1433 in my client's Computer.
I have checked my ODBC Data Source Administrator (both 32 & 64-bit) and I found out I have SQL Server Native Client RDA 11.0 installed which my client does not have. I researched and it's no longer possible to install this version. I also found out about SQL Server Compact 3.5 which supposedly comes with a replacement to RDA called Synchronization Services for ADO.NET. I installed both 32 & 64-bit versions in both my computer and my clients.
I have also tried establishing a Remote Desktop connection with my own login info but when I test my user form or run my Tester. UDL to attempt to connect to this server I get the same error message.
This is the string I'm using to establish this connection:
conn.Open "Provider=SQLOLEDB;Data Source=PCNAME\SQLEXPRESS;Initial Catalog=DATABASENAME;Integrated Security=SSPI;Trusted_Connection=Yes"
conn.Execute "INSERT INTO dbo.TABLENAME (COLUMNNAME, COLUMNNAME2) values ('" & sColumnVariable & "', '" & sColumnVariable2 & "')"
My question will be:
How do I manage to allow clients to successfully insert into this SQL Database/Table?
Where does the problem lie?
Does it lie within my Computers Settings?
Does it lie within my Clients Computers Settings?
Does it lie within my SQL Server Management Studio (maybe wrong/missing permissions)?
I appreciate your help in advance!
Regards, Dave.
You have to use the IP address to connect, for example:
Data Source=101.101.101.101\SQLEXPRESS;
Open a DOS prompt on the machine where SQL Server Express is located and type ipconfig
Get IP address and use it in your connection string
LocalHost just refers you your own computer. So unless you have a SQL Express running on each of the client computers, it isn't going to work.
You need to use the proper computer name or an IP address.
Is SQL Express running on a Windows Server?
I'm pretty sure that this is a requirement if you want other computers to talk to your SQL Server Express database. It's fine to use to test locally, but you need to install SQL Server on an PC that is actually running Windows Server to be able to accept and route the connections properly. So while SQL Server Express if free, your going to have to pay for Windows Server if you don't already have one.
If not, I'd love to know to get around dealing with my IT department so I can get something done.
I was able to figure this out. It had to do with the IP. I used my Local Area Connection IP address ONLY, without \SQLEXPRESS along with a new user I created in SQL Server Management Studio in my connection string:
conn.Open "Provider=SQLOLEDB;Data Source=IPADDRESS;Initial Catalog=DATABASENAME;Integrated Security=SSPI;User ID=MySQLTest;password=myPassc0de;
I'm soooo happy.

Unable to Add Azure DB Firewall Rule to Allow Build Server to Run Tests

We use a Visual Studio Online-hosted build server to automate our build process. As part of this I'm looking into adding unit and integration tests into this process.
These tests require access to our SQL Azure DBs (2 of them, both on the same server), which in turn requires access through the DB server's firewall.
I have a PowerShell script which uses New-AzureRmSqlServerFirewallRule to add IP addresses to the DB server, and these firewall rules are successfully showing up in the Azure portal.
Specifically, the script adds firewall rules for:
All IPv4 addresses* on the build server (as returned by Get-NetIPAddress)
Build server's external IP address (as returned by https://api.ipify.org)
In conjunction, it appears that the pre-defined AllowAllAzureIPs and AllowAllWindowsAzureIps rules are automatically added.
However, the tests subsequently fail with the exception:
System.Data.SqlClient.SqlException:
System.Data.SqlClient.SqlException: 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)
I'm unsure why the build server is unable to reach the DB server - could it be that the host of the test processes is using yet a different IP address?
Update
As has been pointed out, the exception message mentions "Named Pipes Provider" which suggests that the DB connection is using a named pipe instead of an IP/TCP connection. To test this I changed the local app.config to contain an unknown/random/inaccessible IP and ran the tests locally (they otherwise run successfully locally): I received exactly the same exception message mentioning "Named Pipes Provider". Perhaps at some level the ReliableSqlConnection class resolves to a named pipe but my point is that I can induce this very same exception by changing to an unknown or inaccessible IP address in my DB connection string.
Furthermore, the DB connection string starts with tcp: which, as per this blog post, explicitly tells the connection to use TCP/IP and not named pipes.
I have also modified the firewall rule to permit all IP addresses (0.0.0.0 to 255.255.255.255) but the same exception is still thrown. This suggests that the SQL Azure firewall rule is not the cause of the 'blockage'.
My suspicion therefore turns to network access being blocked (though a whitelist is probably present to permit the build server to reach the code repository). I added a very simple PowerShell script to the start of the build process:
Test-Connection "172.217.18.100" #resolves to www.google.com
This results in
Testing connection to computer '172.217.18.100' failed: Error due to lack of resources
Have the build servers disabled ping/ICMP or is all outgoing traffic blocked?
* The script only considers IPv4 addresses because I haven't had any success in passing IPv6 addresses to New-AzureRmSqlServerFirewallRule.
We finally solved the issue. The problem had nothing to do with Firewalls. The issue was that the app.config files in our unit test didn't go through the transformation step that our web.config files did. So all the settings were from our local development and therefore wrong.
More about this here:
Connect to external services inside Visual Studio Online build/test task
What connection string are you using? Your error seems to indicate that this is not truly a firewall issue, but rather a connection is being attempted to a server that doesn't exist.
My * incorrect * hypothesis right now is that your connection string contains only the server name, without .database.windows.net suffix which causes the client driver to look for server on local network. The error presented appears to not be a firewall related issue.
( Edited to reflect author feedback. )
If you're connecting over TCP, then why is your error message saying Named Pipes?
[...]
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I'd look into this paradox first.
The firewall test is very simple, allow 0.0.0.0 to 255.255.255.255 or 0.0.0.0/0 and re-test. My money is on the same error message.

Cannot connect to dbdash from DataGrip

In DataGrip, I'm using the DB2 (JTOpen) data source/driver and supplying the connection information directly off of the dashdb "connect" tab. When trying to connect to my dashdb, I keep getting the following error:
I am using the stock information as supplied on the "Connect" tab of the dashDB dashboard:
Has anyone been successful connected to dashDB with DataGrip?
dashDB shares technology with DB2 LUW and you need to use the DB2 LUW-specific connection type, not the one for DB2 on IBM i (AS/400). dashDB has been successfully tested with all kinds of tools.
Try jdbc:db2://...

Resources