i want to create a report, which would connect to current sql server and execute sql statement(s), which would create some triggers. basicly, i want to make an installation report.
now another problem - i've scripted the trigger as sql script, and it works fine in query window, but i'm not sure how to execute multiple statement query using ADO, it complains for example about GO statement..
how complex is your statement. if it is more than 1024 char, make a sql scalar function with parameters and call this function with params from navision (also with ado)
well, i can't make a function in sql, because the whole purpose of my report is to simplify deployment, that is to automate trigger creation, so that end user doesn't have to open management studio and do things manually
We have this solution.
This simple code is in a button in Sales Order form and good thing is we can pass dynamicly parameters to the select statement like "Order No.", "posting date" e.t.c
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
http://www.mibuso.com/forum/viewtopic.php?t=23038
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Here you have the Server Name (Host + SQL Instanc if named instance).
Than you can open an connection to the sever with using ADO (Search the forum for this)
now another problem - i've scripted the trigger as sql script, and it works fine in query window, but i'm not sure how to execute multiple statement query using ADO, it complains for example about GO statement..
anyway, i think i've sorted it out already
This simple code is in a button in Sales Order form and good thing is we can pass dynamicly parameters to the select statement like "Order No.", "posting date" e.t.c
sqlfile.CREATE('c:\Cargo\Cargo4.sql');
batfile.CREATE('c:\Cargo\sql-test4.bat');
sqlfile.WRITEMODE:=TRUE;
sqlfile.TEXTMODE:=TRUE;
batfile.WRITEMODE:=TRUE;
batfile.TEXTMODE:=TRUE;
sqlfile.WRITE('SET NOCOUNT ON');
sqlfile.WRITE('SELECT dbo.[XXXXXXX$XXXXXXXXXXXX].[XXXXXXXXX] );
Name:='C:\XXXX\XXXX;
batfile.WRITE('sqlcmd -S SERVER5 -U reprt -P s0g00d -d Orbit -s '+" "+' -k 2 -W -m 10 -i C:\Cargo\Cargo4.sql -o '+Name+'.txt');
sqlfile.CLOSE;
batfile.CLOSE;
SLEEP(3000);
SHELL('c:\Cargo\sql-test4.bat');