views:

698

answers:

2

What steps do I take? Any gotchas to be aware of or tips to enhance the IDE experience that are specific to SQL Server when using Emacs?

+2  A: 

To start, look at SQL mode.

Svante
broken link . . .
Hassan Syed
Thanks for noting, it is fixed now.
Svante
+12  A: 

Connecting

To connect to a SQL Server database instance from Emacs:

M-x sql-ms RET
M-x sql-mode

You will be prompted for standard connection information specifically the following:

  • User
  • Password
  • Server
  • Database

For SQL Server Authentication, type in the necessary user and password info. However, if connecting via Windows Authentication, then press RETURN for both user and password leaving them blank.

Viewing Output Results

Note that to see the text of any output results in the *SQL* buffer, the 'go' statement should be called at some point. A couple of ways of doing this.

For example, this sql statement will execute but it will not show any result text in the *SQL* buffer in its current format:

select 'foo' as bar

However, if a 'go' is appended to the end:

select 'foo' as bar
go

the following will be displayed in the *SQL* buffer:

 bar   
 ----- 
 foo

(1 row affected)

Alternatively, if you do not want to have 'go' statements littering the text of your SQL script then call 'go' on the fly to see all output results since the last time that the previous 'go' statement was sent to the sql process:

C-c C-s go RET

This is helpful if you need to view any error messages that might not initially show in the *SQL* buffer.

Ray Vega