With SS_EXECUTE_SQL COMMAND.exe. You can execute a SQL query with the command line:
SS_EXECUTE_SQL_COMMAND.EXE CS ". \ FILE.SQL" 1 @ P1 @ P2 @ P3 ... @ Pv
CS = Connection String of SQLSERVER
ex: Data Source = SQLSERVER; Initial Catalog = DATABASENAME; Persist Security Info = True; User ID = SA; Password = 123456
".\FILE.SQL" = The file that contains the sql query.
.\ means it is on the application path.
Alternatively it can be full path eg: "c:\my data\query.sql"
1 = form visible, or 0 = form invisible
@ P1 @ P2 @ P3 ... @ Pv = parameters that the query can contain. (optional)
EXAMPLES:
1) SS_EXECUTE_SQL_COMMAND.EXE "Data Source=SQLSERVER;Initial Catalog=DATABASENAME;Persist Security Info=True;UserID=SA;Password=123456" ".\FILE.SQL"
Executes the sql query written in the FILE.SQL file in the background.
2) SS_EXECUTE_SQL_COMMAND.EXE "Data Source=SQLSERVER;Initial Catalog=DATABASENAME;Persist Security Info=True;UserID=SA;Password=123456" .\FILE.SQL" 1
Executes the sql query written in the FILE.SQL file with the wait form visible.
3) SS_EXECUTE_SQL_COMMAND.EXE "" ".\ FILE.SQL"
Executes the sql query written in the FILE.SQL file in the background.
The Default_CS.txt file is required in the application path that will contain the Connection String.
4) SS_EXECUTE_SQL_COMMAND.EXE "" .\FILE.SQL" 1 "01/01/2014" "01/31/2014"
Executes the sql query written in the FILE.SQL file with the wait form visible.
The Default_CS.txt file is required in the application path that will contain the Connection String.
The ILE.SQL file has two parameters:
e.g:
Update [Docs]
Set [Value1] = 1
WHERE [DocDate] Between ('@ p1', '@ p2')
The following files are saved at the end of the process:
ERRORS.LOG = Includes the result of the process.
Result.txt = Includes true (success) or false (failure)
tmp_EXEC_SQL.sql = Query as sent to SQL SERVER.
Get the app by making a donation here.