Search for SQL output parameterized query

I am making a parameterized query using C # against an instance of SQL Server 2005, and I would like to take a look at SQL that runs against the database for debugging purposes. Is there somewhere I can see what the output SQL command with parameters is, either in the database logs or in the Visual Studio debugger?

+7
c # sql-server parameterized-query
source share
2 answers

SQL Profiler is a better solution, but if you need something more organic for your application that you could deploy and enable / disable during production, QA, etc ... then you could create a wrapper around System. Data.SqlClient Provider (for example, a provider registered in the configuration file as ... providerName = "System.Data.SqlClient").

This will essentially act as an interception proxy that will give you access to all information passing through the Provider (for example, between your application and the database client). This will allow you to pump what you need, intercept, modify, aggregate and / or enrich it. This is a bit more advanced, but it opens the door to capturing a range of information and can be inserted / replaced / deleted as a separate level of problems.

+1
source share

All Articles