5

I need to query a MS SQL Server database from a linux terminal. Searching the web and this site I found freetds and then sqsh. I have installed them and seems to connect to the server but I can't get it to execute a query, I'm definitely doing something wrong.

I have configure freetds as:

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

The databse server is a Sql Server 2008 r2.

When connecting I use the following command:

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

Which gives me a prompt 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 like:

1> select * from C_PROPS;

But nothing happens. What am I doing wrong?, just need simple selects and updates.

1 Answer 1

5

I think that the semicolon_hack variable is not set.

You need to write your command like this

select * from C_PROPS
go

or, at the beginning of a sqsh session

\set semicolon_hack=on
go

now you can do

select * from C_PROPS;

or, alternatively, create a .sqshrc in your home directory and insert this snippet

#
# $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
Sign up to request clarification or add additional context in comments.

1 Comment

Thx, I didn't thought about the 'go', in management studio (and when using postgres or mysql) I always end statements with ';'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.