How to pass a value from X++ code to SP (stored Procedure)

Hey,

I am trying to pass my companyID (DataAreaID) into a SQL Procedure. What is the format?

SQLconnection = strfmt(“EXEC [SP]”)

where do we pass the Paramater companyID?Can you give me that code?

For example: str sqlCmd = strFmt(“EXEC MySP %1”, companyID).

If you don’t know how to use strFmt(), look at a few examples.

If you don’t know how to use stored procedures, it has nothing to do with Dynamics AX and therefore you can follow documentation and code samples written directly for SQL Server. (Assuming that your DBMS is SQL Server, which you unfortunately forgot to mention.)

Thanks for the reply Martin.

It is a SQL server… I am still getting this error!

SQL error description: [Microsoft][SQL Server Native Client 10.0][SQL Server]Procedure or function ‘SBS_Load_Formula_AX_New’ expects parameter ‘@DATAAREAID’, which was not supplied.

@DATAAREAID is the input parameter for the SP.

You have to fix your code by providing a value of the parameter. Please make sure you test your T-SQL code before trying to call from AX.

I can’t be any more specific unless you become more specific.