Debugging Stored Procedures
Analysis Services stored procedures are actually CLR or COM libraries (normally DLLs) that are written in C# (or any other CLR or COM language). Therefore, debugging a stored procedure is much like debugging any other application in the Visual Studio debugging environment. You debug stored procedures in the Visual Studio development environment using the integrated debugging functions. These allow you to stop at procedure locations, inspect memory and register values, change variables, observe message traffic and get a close look at how your code works.
To debug a stored procedure
Open the project used to create the DLL in Visual Studio.
Create breakpoints in the method or function corresponding to the procedure you want to debug.
Use Visual Studio to create a debug build of a stored procedure DLL.
Deploy the DLL to the server. For more information about deploying the DLL to the server, see Creating Stored Procedures.
You need an application that calls the stored procedure that you want to test. If you do not have one ready, you can use the MDX Query Editor in SQL Server Management Studio to create an MDX query that calls the stored procedure that you want to test.
In Visual Studio, attach to the Analysis Services process (Msmdsrv.exe).
From the Debug menu, choose Attatch toProcess.
In the Attatch toProcess dialog box, select Show processes from all users.
In the Available Processes list, in the Process column, click Msmdsrv.exe. If there is more than one instance of Analysis Services running on the server, you need to identify the process by the ID of the instance you want to use.
In the Attach to text box, make sure that the appropriate program type is selected. For a CLR DLL, click Select, then click Debug these code types, then click Managed, then click OK. For a COM DLL, click Select, then click Debug these code types, then click Native, then click OK.
Click Attach.
In Analysis Services, invoke the program or MDX script that calls the stored procedure. The debugger breaks when it reaches a line containing a breakpoint. You can evaluate variables in the watch window, view locals, and step through the code.
If you have problems debugging a library, make sure that the corresponding program database (PDB) file was copied to the deployment location on the server. If this file was not copied during registration or deployment, you must copy it manually to the same location as the DLL. For native code (COM DLL), the PDB file resides in the \debug subdirectory. For managed code (CLR DLL), it resides in the \WINDEBUG subdirectory.