Executing ms sql server requests from linux terminal

I need to query the MS SQL Server database from linux terminal. Searching the Internet and on this site I found freetds and then sqsh. I installed them and it seems to connect to the server, but I can not get it to execute the request, I definitely have something wrong.

I install freetds as:

[MSSql]
        host = 192.168.1.4
        port = 1433
        tds version = 7.0

The database server is Sql Server 2008 r2.

When connecting, I use the following command:

sqsh -S MSSql -U sa -P sa -D databasename

Which gives me a hint like:

sqsh-2.1.7 Copyright (C) 1995-2001 Scott C. Gray
Portions Copyright (C) 2004-2010 Michael Peppler
This is free software with ABSOLUTELY NO WARRANTY
For more information type '\warranty'
1>

Then I try to enter a query, for example:

1> select * from C_PROPS;

But nothing happens. What am I doing wrong? It just needs simple selections and updates.

+4
source share
1 answer

I think the variable is semicolon_hacknot set.

select * from C_PROPS
go

, sqsh

\set semicolon_hack=on
go

select * from C_PROPS;

, , .sqshrc

#
# $semicolon_hack : This turns on the ability to use a semicolon as
#             a sort of in-line go.  It is kind of hacky but seems
#             to work pretty well.
#
\set semicolon_hack=on
+5

Source: https://habr.com/ru/post/1523875/


All Articles