Error executing sqlcmd command through UNIX


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Error executing sqlcmd command through UNIX
# 1  
Old 06-21-2015
Error executing sqlcmd command through UNIX

Hi All,

I am trying to execute a set of sql statements in sql server 2008 using the sqlcmd command in unix and passing the query in the "input" parameter. It is giving me an error "incorrect syntax near 2014". The below statement is giving an error :

Code:
 declare date_val datetime,
 select @date_val = '2014-01-01 23:00:00:999'

I have used the same sql in sql server database and it is working fine by but when I am using ''2014-01-01 23:00:00:999'' in sql server directly the it is throwing the same error.

Please suggest how this can be resolved.

Thanks in advance!
# 2  
Old 06-21-2015
Is it expecting 23:00:00:999 or 23:00:00.999? Most systems I've seen use a period to separate seconds from milliseconds; not a semicolon.
# 3  
Old 06-22-2015
Hi Don,

It is a typo mistake. The date is @date_val = '2014-01-01 23:00:00.999' only. Thanks for pointing it out.
The same sql is working in sql server but giving error in unix.

Please suggest.
# 4  
Old 06-22-2015
  1. Show us the entire script, not just two lines from the SQL query, and show us the entire, exact diagnostic message (both in CODE tags) that you get when you run that script.
  2. What shell is being used to run your script?
  3. What operating system (including release number) are you using? If you don't know the release, show us the output from the command: uname -a (also in CODE tags).
  4. What operating system is running on the system where your database is running?
  5. What database software are you using?
Without the above basic information, we have a much very limited chance of offering any real help.
# 5  
Old 06-22-2015
I was able to run SQL Server commands from Linux using the following command:
Just substitute your ip address, instance port and username. You can store the
password in the SQLCMDPASSWORD variable. The -e flag echo's input, the -b flag
causes it to abort on error, and the -i flag specifies the input file.

Otherwise it was running proper SQL Server syntax. I did add a GO between each
command. You may need to do the same.

Code:
SQLCMDPASSWORD=<pwd>
sqlcmd -U "<username>" -S <server ip address>,<server port> -e -b -i sql_to_run.sql

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to find IP of user machine executing a particular UNIX command?

Hello, Our applications are deployed in SunOS 5.10 servers. All the team members use a same username/pwd to login to the box. Very often we face issue were we could see that weblogic server instance are KILLED and we are not able to trace who executed kill command. All team members use PUTTY to... (2 Replies)
Discussion started by: santtarius
2 Replies

2. Shell Programming and Scripting

Error while executing sh command

Hi, I have 2 files temp1.sh and temp2.sh as follows: =========== temp1.sh =========== echo "session1" sh temp2.sh echo "exit session2 and enter session1" ================================= ============= temp2.sh ============= echo "session2" sh echo "exit session2"... (5 Replies)
Discussion started by: RP09
5 Replies

3. Red Hat

Error while executing isql command on RHEL4

Hi, I am using RHEL4 and Oracle11g , my application requires odbc connection hence I modified ODBC.ini file and when I exceute isql commande I got the following error. isql: error while loading shared libraries: /opt/nastel/apwmq/odbc/lib/libodbc.so.1: requires glibc 2.5 or later dynamic... (4 Replies)
Discussion started by: roopalidalvi231
4 Replies

4. Red Hat

Error while executing isql command on RHEL4

Hi, I am using RHEL4 and Oracle11g , my application requires odbc connection hence I modified ODBC.ini file and when I exceute isql commande I got the following error. isql: error while loading shared libraries: /opt/nastel/apwmq/odbc/lib/libodbc.so.1: requires glibc 2.5 or later dynamic... (1 Reply)
Discussion started by: roopalidalvi231
1 Replies

5. AIX

Error while executing command in aix box

Hi Folks I get the below error in my aix box. Im not sure if this is an AIX issue or a TWS issue. Please advice me cbspsdb01:/opt/TWS/bin # ./conman status exec(): 0509-036 Cannot load program ./conman because of the following errors: 0509-150 Dependent module... (6 Replies)
Discussion started by: newtoaixos
6 Replies

6. Shell Programming and Scripting

Executing a variable that strores a unix command string

Hi: I have a touble with executing a variable that stores a unix command string. The following would be excuted fine: command='ls -l' `echo $command` However, the following gives me an error: command='(uuencode file1 file1; uuencode file2 file2) | mailx email_id' `echo... (1 Reply)
Discussion started by: sagewise
1 Replies

7. Shell Programming and Scripting

error while executing the mail command

Hi, I am getting an error while executing the mail command.... It says saved letter in dead.letter even though the email id id correct . Please do help.. Madhu (2 Replies)
Discussion started by: madhumathikv
2 Replies

8. UNIX for Dummies Questions & Answers

Executing a unix command

Hi, I need to execute the following unix command through my java code - zip -e When i execute this command from the command prompt, i am prompted for a password in the following manner - Enter password: Verify password: Is it possible to provide the password inthe first command itself... (5 Replies)
Discussion started by: jacob23
5 Replies

9. Shell Programming and Scripting

executing *.bat file on windows from Unix box via ftp command

I have created get_list.bat file containing following line: dir /B /O-d >file_list.txt I am executing ftp command from Unix box and transferring get_list.bat file to windows server. In my next ftp command I am trying to execute this test.bat file by entering this line: get_list or by... (9 Replies)
Discussion started by: alx
9 Replies

10. UNIX for Dummies Questions & Answers

Executing UNIX command from java on NT

Hi - I am totally new to UNIX so please bear with me... I run a java program on Win NT server to do file ftp to UNIX server. I log in, cd, create ftp file on UNIX and quit from my java progam - all works well. Now I want to execute a script on UNIX. At the UNIX 'console'/'shell' (!?) you... (1 Reply)
Discussion started by: CJ Walt
1 Replies
Login or Register to Ask a Question