# Can connect to SQL Server through tsql but not from the bsqldb

After installing FreeTDS I was able to connect to our SQL Server using tsql but not yet through bsqldb. With bsqldb it's trying to connect to the master even though the db was specified to testDB.

serverName is setup in /etc/freetds.conf

[serverName]
host = database.windows.net
port = 1433
tds version = 8.0


Using tsql:

[gpadmin@mdw ~]$/usr/bin/tsql -S serverName -U user -D testDB -P password  works fine With bsqldb it's trying to connect to the master even though the db was specified to testDB. [gpadmin@mdw ~]$ /usr/bin/bsqldb -U user -P password -S serverName \
-D testDB -i tag.sql -o tag.csv

Msg 4060, Level 11, State 1
Server 'fj5j2jtt5k', Line 1
bsqldb: error: severity 11 > 10, exiting


I know this is an old question but for the sake of "drive by googlers" I shall attempt an answer.

I'm assuming you know the backslash doesn't belong in your cmd line and that the servername showing in your output is something random you typed to hide the actual name.

Its got info on troubleshooting your config.

Use this command to confirm your instance / server config:

tsql -LH servername


Make sure your pointing to the proper port, remember you can only specify an instance OR a port, not both.

Once you confirmed your settings use this command to connect to the server and open an interactive prompt from which you can run SQL commands on the server:

tsql -S servername -U username


You will then have to input your password. Remember this user should be created on the DB server itself and have proper permissions to access your DB. If your dead set on using some directory services instead of a local user read the manual http://www.freetds.org/userguide/

Once your logged in enter this:

USE databasename
GO


You are basically making sure your connecting at the right place, then that you are actually able to log in and then manual try to USE the database. This process should give you a better idea of whats going on.

If it still bugging you with the db "master" after that Id say check your server / instance config. Also make sure your using the proper TDS protocol version.