Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Support for MSSQL #120

Closed
1 of 4 tasks
anengineerdude opened this issue Jul 5, 2017 · 20 comments · Fixed by #168
Closed
1 of 4 tasks

Support for MSSQL #120

anengineerdude opened this issue Jul 5, 2017 · 20 comments · Fixed by #168

Comments

@anengineerdude
Copy link

anengineerdude commented Jul 5, 2017

Issue Type

  • Feature Request
  • Bugfix/Errors
  • Questions
  • Other

Description

No examples/support for MSSQL connections currently. Please help to support Microsoft SQL connections.

@mkormendy
Copy link

This has already been addressed, please see issue: #52

@mkormendy
Copy link

Per Issue #52 for some reason all my my executions of queries performed on Sublime Text 3 on MacOS, result in the following output:

Sqlcmd: Warning: The last operation was terminated because the user pressed CTRL+C.

@tkopets
Copy link
Collaborator

tkopets commented Aug 30, 2017

@mkormendy
Are you saying that it used to work before with your custom configuration, but now it doesn't work anymore?

tkopets added a commit that referenced this issue Aug 30, 2017
So far tested only on Windows.
Related to #120 #52
@tkopets
Copy link
Collaborator

tkopets commented Aug 30, 2017

I've added basic support for MSSQL in the recent pull request #135.
As a starting point, I used config listed in #52 by @mkormendy and tried to make it work with the latest version of SQLTools.
So far it was tested and appears to be working on my local Windows machine.
Testing it on Mac and Linux would require setting up a lot of things and I'm not sure I will be able to do it in next few days.
I would appreciate if you can help testing MSSQL support on Mac, Linux.
If you do please make sure to remove all the additional configuration you added to your SQLTools settings file.
You will find examples of how to configure the connection in default Connections file.

@mkormendy
Copy link

mkormendy commented Aug 30, 2017

@tkopets re: #120 (comment), no it never worked.

I performed some testing on the command line directly with MacOS homebrew version of sqlcmd. While the format is identical to the Windows CLI,.. SQLTools seems to not wait for the response from the sqlcmd command before cutting the process off, using the configuration suggested in issue #52.

Let me pull your latest changes and test.

@tkopets
Copy link
Collaborator

tkopets commented Aug 30, 2017

@mkormendy
Copy link

mkormendy commented Aug 30, 2017

Yeah I tapped the Homebrew install on the release cask, so I'm working with the latest.

@mkormendy
Copy link

mkormendy commented Aug 30, 2017

I was able to set it up, but I get a different error now:

Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2726. 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..

The command line method still works properly and outputs the records.

@tkopets
Copy link
Collaborator

tkopets commented Aug 31, 2017

The command line method still works properly and outputs the records.

Can you post the command line that works for you?
So I can compare with what is being generated by SQLTools.

@tkopets
Copy link
Collaborator

tkopets commented Aug 31, 2017

I started testing sqlcmd on Mac and I found that sqlcmd on Mac does not work with standard input and result in error message you posted above:

Sqlcmd: Warning: The last operation was terminated because the user pressed CTRL+C.

Here is a simple test I performed:
echo "select 1;" | sqlcmd -S IP,PORT -U xxx -P xxx -d xxx

Until sqlcmd is fixed to accept queries from standard input this will not work with SQLTools on Mac.
Note: it is working fine and accepting sql from standard input on Windows.

I'm not even sure where to report this bug.
If you have an idea, please submit this bug request to Microsoft.

@mkormendy
Copy link

mkormendy commented Sep 4, 2017

Hrmm .. when I run the following on my Mac at the bash prompt:

sqlcmd -S "serverorIP,port" -U "username" -P "password" -d "database" -Q "select 1;"

It returns:

-----------
          1

(1 rows affected)

I don't need to pipe the query from an echo statement into the command or otherwise .. it just returns the results directly.

I have posted an issue on the github repo for the homebrew installer for the sqlcmd tools. The maintainer of the installer is also the author of the blog post, so hopefully he will be able to pass the issue along to the internal MS team.

@tkopets
Copy link
Collaborator

tkopets commented Sep 5, 2017

Thanks for submitting the bug request to homebrew installer project!!!

Yeah, executing a single command with -Q flag works for me as well, but SQLTools relies on CLI to be able to accept and process SQL commands from standard input.
As seen here:
https://github.com/mtxr/SQLTools/blob/072301ea9f007c73fc68af2ab15a1ab1fd403f11/SQLToolsAPI/Command.py#L60-L93

On Windows sqlcmd works with stdin as expected, but on Mac it doesn't.

@nikme
Copy link

nikme commented Sep 7, 2017

Just for info;
Query is executing by row, if you split query in multiple rows, without marking whole query it will give back error and execute only part where is pointer.

It would be great if nothing is selected, on run, whole code is executed; and if portion of code is selected, only that part is executed. This schema is in MS SQL SMS.

I'm posting under this issue because I'm not sure is it global decision or mssql case only.

@tkopets
Copy link
Collaborator

tkopets commented Sep 8, 2017

@nikme
Please don't hijack this thread with an unrelated topic, instead create a separate issue.

@mtxr
Copy link
Owner

mtxr commented Dec 5, 2017

@tkopets in can test it tomorrow also test your pull request.

@mtxr
Copy link
Owner

mtxr commented Dec 14, 2017

Hey guys, could you please test the pull request #167 ?

It's supposed to fix this problem, but it's a quite ugly. Till MS solves sqlcmd problem, we can work it around.

@mkormendy
Copy link

Apologies for getting back just now, I will test this over the weekend.

@tkopets
Copy link
Collaborator

tkopets commented Jan 5, 2018

Great!
If that works well for you I will prepare a new release.

@tkopets
Copy link
Collaborator

tkopets commented Jan 12, 2018

@mkormendy
Have you had a chance to test this out?
I plan to prepare a new release mid next week so if you don't want to mess with checking out the source code you can do it after release (via Package Control).

@mkormendy
Copy link

mkormendy commented Jan 16, 2018

I tested this. It works as expected now! SUCCESS!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.