SMS Server Tools 3
This site is hosted by Kekekasvi.com
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Sun Mar 07, 2021 11:01
SMSTools3 Community » Help and support Bottom

Using SQLCMD SQL command Line Interpreter

Login and Post Reply

Page:  1

Author Post
Member
Registered:
Jan 2010
Location: Bristol, United Kingdom
Windows 7 64Bit:
3.1.14:
Smsd installed from: sources / package repository / from elsewhere...
Huwei:
USB: serial / USB / some adapter...

Hi Keke,
I'm trying to use the SQLCMD Utility to add and read records from an MS SQL Lite database. I can get it to work from the Cygwin command line but cannot get it to run from an SMSD script.

If I Use this format directly in Cygwin it works no problem;
sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES ('4827771902','DVR','DVR')"

Using the following in a script;
sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES ("'4827771988'","'DVRS'","'DVRS'")"

Or this;
sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES (/"4827771988/",/"DVRS/",/"DVRS/")"

Doesn't add any records.

I am testing at the moment so the above is the only line in the script, which is called Test and I am running it directly from the cygwin command line.



I'm sure there is a simple solution but cannot get there. Any ideas to help?

Regards

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
bill1798 wrote
Or this;
sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES (/"4827771988/",/"DVRS/",/"DVRS/")"

It should work with backslashes:

sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES (\"4827771988\",\"DVRS\",\"DVRS\")"

If it still does not work, what is the error message when you run it from the command line?

Member
Registered:
Jan 2010
Location: Bristol, United Kingdom
Topic owner
Hello Keke,
Thanks for your advice, it's been a while since I tackled the script language in SMS Tools so I am out of practice. As it turned out my Test program was not executable and so it wasn't doing anything once I resolved that then it didn't take too long to work out the correct syntax for SQL Lite. I have now changed my MYSMSD event handler to work with SQL and it seems to work well using the SQLCMD program. If it helps anyone else here is what the modified event handler looks like.



As you can see SQL uses single quotes around the table column values and no / delimiters, it also doesn't like the ;"; at the end of the SQL strings preferring just a " . The SQL_ARGS string uses different switches from MYSQL but apart from that everything is pretty much the same.

Regards
Bill M

Login and Post Reply

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.