Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
2 answers
332 views

looping infinitely when using sqlcmd inside a while-loop body

I have a bash script which uses sqlcmd for fetching data from database in a while-loop body: #!/bin/bash tmpfile=$(mktemp) echo -e "1\n2" > tmpfile echo "---------------content from ...
Raindy's user avatar
  • 921
0 votes
1 answer
254 views

Bash loop to read file line by line problem with sqlcmd

I'm reading a .txt file using a while loop: baseFileDir=./Base_Database_Files/ if [ -f "./SqlFiles.txt" ]; then while IFS= read -r line || [[ -n "$line" ]] do ...
Farrukh Waheed's user avatar
0 votes
1 answer
233 views

Git bash and sqlcmd

I'm using a shell script in git bash to call sqlcmd to run some sql scripts. The script names are based on the git branch name, so the command is sqlcmd -E -S mySQLServer -d myDB "$branchsql"...
Flimbin's user avatar
0 votes
0 answers
626 views

Docker-compose.yml file with startup.sql not working

I create my MSSQL database docker container with only docker-compose.yml file and setup.sql file. My .yml file looks like that: version: "3.7" services: sql-server-db: container_name: ...
patplo1999's user avatar
0 votes
1 answer
300 views

Not able to run the sqlcmd due to incorrect syntax

I am trying to run the sqlcmd in a bash script, however it's giving syntax error as it's not able to cast the column - sqlcmd -S $DB_HOST -U $DB_USER -P $DB_PASSWORD -o $mssqlresult -s "," ...
RAHUL SONI's user avatar
0 votes
1 answer
211 views

bash sqlcmd variable array

I´m trying to acces values in a variable I receive from an sqlcmd in a loop: while read line ;do AllNumbers=`sqlcmd -h -1 -S mysqlserver.localdomain -U Me -P MyPasswd -d master -Q "SET nocount on;...
Lothar Albrecht's user avatar
0 votes
1 answer
654 views

Sqlcmd: 'var=1': Invalid argument. using Bash Script

This is my first post in stackoverflow :D I'm having a problem in passing variables in sql file using sqlcmd. sqlcmd -S "$host" -U "$username" -P "$password" -d "$dbname" -s "║" -v test=1 -i $...
Jonel Zape's user avatar
0 votes
1 answer
215 views

When is Azure SQL ready to receive queries?

Problem When I deploy an Azure SQL Database, I would like to make some queries immediately after (on the Azure DevOps agents). Is there any way to find out when it is ready to receive queries? ...
Esben Eickhardt's user avatar
0 votes
0 answers
14 views

Cron job does not execute a bash file that use sqlcmd [duplicate]

I have a sqlserver 2017 in an ubuntu 16.04 server working good, so I made a script for backup my database automatically, for this I create a bash file: sqlcmd -U sa -P xxx -S xxxxx -d COMPART -i /...
Diego Chilomer's user avatar
0 votes
1 answer
833 views

Using a bash variables in sqlcmd

I have been tasked with replacing ISQL in a lot of our bash scripts with sqlcmd. ISQL allows piping a variable in it's execution. An example would be: SQL_STATEMENT="SELECT TOP 1 SYS_USER_NAME ...
Clint's user avatar
  • 175
0 votes
1 answer
88 views

Run command, and then add results via SQLCMD

I am trying to run a command in bash and then output the results to a DB using SQLCMD The below is my partial script commandResults=$(/home/techionadmin/ssh.sh ${d9} "${d5}") newcmd=${commandResults}...
James_Inger's user avatar
0 votes
2 answers
10k views

How to iterate over bash sqlcmd output

I have a SQLCMD in linux bash that im getting the results of a SELECT, how can i iterate over each line, and be able to pick out specific columns so that i can use them to run a bash command on I ...
James_Inger's user avatar
1 vote
1 answer
2k views

sqlcmd works in CMD and not in bash

I am having quite a few problems making MSSQL drivers work in Ubuntu. I have followed the following tutorial to make sqlcmd work in Ubuntu 16.04. # In CMD: sqlcmd -S my_server_name -U my_username -P ...
Esben Eickhardt's user avatar
-1 votes
1 answer
367 views

Linux, Bash Script - Loop through sqlcmd connection SELECT results

Linux, Bash Script. I have created a query as below, which works sqlcmd -S [dbname].database.windows.net -d [database name]-U [username ]-P [password] -Q "SELECT * FROM dbo.microiopenvpn WHERE mode='...
James_Inger's user avatar
3 votes
1 answer
1k views

loop variables stuck as constant when using sqlcmd

While creating a bash script that calls sqlcmd for different variables in a loop, noticed it appears to be setting the loop variables that should update in the loop to be constant once it is called ...
lampShadesDrifter's user avatar
9 votes
2 answers
3k views

Trouble connecting to SQL Server with sqlcmd from inside Docker

Working with debian linux inside a docker contaier. I have sqlcmd working properly and the neseccary drivers are installed and locatable. I know the server exists: root@0feafecac36f:/home/shiny# nmap ...
Stu's user avatar
  • 1,633
3 votes
1 answer
494 views

sqlcmd return only count - suppress text

I have a bash file which executes a SQLCMD query to check for the existence of a database: sqlcmd -S localhost -U sa -P $SA_PASSWORD -d master -Q "SET NOCOUNT ON SELECT count(*) FROM master.sys....
user3437721's user avatar
  • 2,279
-1 votes
1 answer
3k views

sqlcmd in bash file - store to variable

Running in a docker container, I am trying to determine if a table exits in the mssql database: RESULT='/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -d master -i "SELECT name FROM ...
user3437721's user avatar
  • 2,279
0 votes
3 answers
7k views

Removing hyphens in SQLCMD

Is that a way to remove dashed line --------- in SQL cmd. E.g: Name ID -------- Alex 13 Alice 22
Lee's user avatar
  • 181