execute sql query from within navision
mrQQ
Member Posts: 239
Hello,
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.
has anyone tried something like this?
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.
has anyone tried something like this?
0
Comments
-
Search for ADO. There are some examples how to use it to connect to current DB...0
-
0
-
amazing, thank you.0
-
hmm, i couldnt exactly find how to get current server hostname..0
-
use the Hostname and SQL Server Instance Name you can use the table Server.
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)Do you make it right, it works too!0 -
thanks, got that sorted out

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..0 -
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)Do you make it right, it works too!0
-
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

anyway, i think i've sorted it out already
0 -
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
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');0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

