Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:15:00+00:00 2026-06-14T23:15:00+00:00

I am able to connect to a Microsoft SQL Server 2008 instance via a

  • 0

I am able to connect to a Microsoft SQL Server 2008 instance via a Mint Linux VM using freeTSD and command line to execute sql statements on it. Now I want automate this in a bash script. I am able to successfully login in my bash script:

TDSVER=8.0 tsql -H servername -p 1433 -D dbadmin -U domain\\Administrator -P password

I then have my SQL query:

USE dbname GO delete from schema.tableA where ID > 5 GO delete from schema.tableB where ID > 5 GO delete from schema.tableC where ID > 5 GO exit

This works when doing manually via freeTSD command line, but not when I put in bash file. I followed this post: freeTSD & bash.

Here is my bash script sample:

echo "USE dbname GO delete from schema.tableA where userid > 5 go delete from schema.tableB where userid > 5 go delete from schema.tableC where ID > 5 GO exit" > tempfile | TDSVER=8.0 tsql -H servername -p 1433 -D dbname -U domain\\Administrator -P password < tempfile

the output of the bash script is:

locale is "en_US.UTF-8"
locale charset is "UTF-8"
Default database being set to sbdb
1> 2> 3> 4> 5> 6> 7> 8> 

and then the rest of my script is executed.

Can someone give me a step by step answer to my problem ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:15:02+00:00Added an answer on June 14, 2026 at 11:15 pm

    I’m not sure how your sample can work at all.

    Here is my bash script sample:

    echo "USE dbname .... exit" > tempfile | TDSVER=8.0 tsql -H servername -p 1433 -D dbname -U domain\\Administrator -P password < tempfile
    # ------------------------------------^^^^ ---- pipe char?
    

    Try using a ‘;’ char.

    echo "USE dbname .... exit" > tempfile ; TDSVER=8.0 tsql -H servername -p 1433 -D dbname -U domain\\Administrator -P password < tempfile
    # ------------------------------------^^^^ ---- semi-colon
    

    Better yet, use shell’s “here documents”.

    TDSVER=8.0 tsql -H servername -p 1433 -D dbname -U domain\\Administrator -P password <<EOS
         USE dbname 
         GO 
         delete from schema.tableA where userid > 5 
         go 
         delete from schema.tableB where userid > 5 
         go 
         delete from schema.tableC where ID > 5 
         GO 
         exit
      EOS
    

    IHTH.

    Current command line input:

    echo "delete from table where userid > 5
    go
    delete from table where userid > 5
    go
    delete from table where ID > 5
    GO
    exit" < /tmp/tempfile; TDSDUMP=/tmp/freetds.log TDSVER=8.0 tsql -H servername -p 1433 -D dbname -U Administrator -P password <<EOS
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am able to successfully connect from access 2007 into SQL Server 2008 using
I was able to connect to MSSQL 2008 express on local machine using SQL
I have mysql DB on cloud linux server. I am able to connect db
I am using JTDS with Java to connect to a Microsoft SQL database. I
In Microsoft Expression 2003, I am able to connect to my client's website using
I need to implement Microsoft's LDAP server signing protocol to be able to connect
I have a 2nd computer that I've installed Microsoft SQL Server 2008 Express on.
I was able to connect to remote SQL server through SQLDMO residing my hosting
I'm running SQL Server 2008 Express on Windows XP on a VirtualPC instance inside
I'm working on a C# application that queries a SQL Server 2008 Express instance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.