DECLARE @Company varchar( 50); DECLARE @Table varchar( 50); DECLARE @EndPoint int; SET @Company = 'Company'; SET @Table = 'TableName'; DECLARE curData CURSOR LOCAL FAST_FORWARD FOR Select DISTINCT EndPoint from [@Company$@TableName] OPEN curData FETCH NEXT FROM curData INTO @EndPoint WHILE @@FETCH_STATUS = 0 BEGIN print @EndPoint -- GET NEXT FETCH NEXT FROM curData INTO @EndPoint END CLOSE curData DEALLOCATE curData
Answers
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
I have the prototype code in SQL, but specific for 1 company now and need to built it into a stored procedure.
---
My Blog: http://NAV-Magno.be
Per default NAV can't run direkt TSQL. Only via ADO or if you use a View and in this view is TSQL (for example the view call a function)
I run this in SSMS (SQL Server Management Studio) just because i can use the speed of SQL Server in my process then. My goal is to create a stored procedure to call in Navision using ADO.
---
My Blog: http://NAV-Magno.be
Because you post it in the NAV/Navision subforum.
OK, also no problem. For ADO here are many examples, and how to create and save a sp under the Management Studio also simple. How to run a sp from NAv with using ADO is also no prob and you found it also if you search the forum.
Is your final question how to display the resultset of the sp in NAV, for example in a form?
The sp and ADO part i have done before.
---
My Blog: http://NAV-Magno.be
Before 5 / 4.03 Update 6 NAv use ever the FF courser type.
http://blogs.msdn.com/microsoft_dynamic ... types.aspx
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
Great, this is indeed what i wanted. I looked into the exec, but didn't know the cursor would be known outside the exec as well.
Thx!
---
My Blog: http://NAV-Magno.be