Microsoft SQL Server in Sublime Text 2?

2019-04-10 01:51发布

问题:

I am a sublime text lover but at my job I am forced to use Microsoft Visual Studio along with Microsoft SQL Server. I want to possibly just use sublime since I'm quite familiar with it and my workflow is just so much better. To do so I would need to know how to run the SQL queries in sublime text? I have been doing some research and found a couple builds but none that work so I'm wondering if it's even possible if so how?

回答1:

It's difficult to create complex IDE from ST2 due it's ascetic UI API.
Even OracleSQL package doesn't give the power of PL/SQL Developer or Toad for Oracle.

So, maybe it's better to join SQLMS with ST. For example write in ST, but run, debug and edit in SQLMS.

Here is my setup for using ST and SQLMS together.

  1. Set up ST to auto re-read file changes if file saved
  2. Set up SQLMS to auto re-read file changes if file saved
  3. Set up External Tool - "Open in Sublime Text" in SQLMS and bind it to ctrl+o,ctrl+s
    command: C:\Portable\Sublime Text 2\sublime_text.exe
    args: $(ItemPath):$(CurLine):$(CurCol)
    dir: $(ItemDir)
  4. Install improved "SQL Ex.tmLanguage" syntax highlight from here

After setup you can open same file in ST and SQLMS and switch between editors easily.



回答2:

Late to this but was just trying to do the same thing.

A very crude solution I just tested in ST3 uses the following (you need to create a new Build system in ST and then associate it with your SQL file)

{
    "cmd": ["sqlcmd", "-E", "-i", "$file"]
}

It uses a trusted connection to SQL and assumes the sql script will either run as-is in the default database, contains a "USE" statement or table names are otherwise fully qualified.

For additional tweaking, run sqlcmd /? from a command prompt or read more here



回答3:

TSQL Easy is a package you can download which has some tools to run TSQL and SQL scripts. It also has good TSQL syntax highlighting in sublime text 2. Actually it's the only TSQL syntax highlighting I've found so far.

You can get the package here (or through package control): https://github.com/tosher/TSQLEasy