0

I am using the SQL Server Profiler to trace the SQL generated from nHibernate in a Windows SmartClient appplication. The trace of the SQL statement does not show actual data, but rather, looks like this:

exec sp_executesql N'SELECT attachment0_.RecordKey as RecordKey1_, attachment0_.Id as Id1_, attachment0_.Id as Id87_0_, attachment0_.RecordType as RecordType87_0_, attachment0_.RecordKey as RecordKey87_0_, attachment0_.FileName as FileName87_0_, attachment0_.OriginalFileName as Original6_87_0_, attachment0_.DateTimeAttached as DateTime7_87_0_ FROM MyDatabase.dbo.tblAttachment attachment0_ WHERE attachment0_.RecordKey=@p0',N'@p0 int',@p0=262

Is there a way to see the the actual data in the SQL command?

Al Lelopath
  • 6,448
  • 13
  • 82
  • 139
  • 3
    It translates to `SELECT attachment0_.RecordKey as RecordKey1_, attachment0_.Id as Id1_, attachment0_.Id as Id87_0_, attachment0_.RecordType as RecordType87_0_, attachment0_.RecordKey as RecordKey87_0_, attachment0_.FileName as FileName87_0_, attachment0_.OriginalFileName as Original6_87_0_, attachment0_.DateTimeAttached as DateTime7_87_0_ FROM MyDatabase.dbo.tblAttachment attachment0_ WHERE attachment0_.RecordKey= 262` – Pரதீப் Mar 29 '16 at 15:38
  • Check NHibernate Profiler by Hibernating Rhinos, it is a good tool. – Alexey Zimarev Mar 29 '16 at 17:11
  • 1
    Just in case it wasn't clear in Prdp's answer - the value of the parameter _is_ there, at the end of the statement. – Oskar Berggren Mar 29 '16 at 19:41

1 Answers1

1

It's just showing the parameterized sql. If you want to log or to show non-parameterized sql I came up with a solution to this here:

Execute NHibernate-generated prepared statements in SQL Server Management Studio

The item of note is the log4net appender that basically translates this in the accepted answer.

Community
  • 1
  • 1
Cole W
  • 15,123
  • 6
  • 51
  • 85
  • The SQL profiler does not only show parameterized SQL but also parameters values, as we can see in his example. In his case, it can even be directly executed in SSMS. (Will not be the case if NHibernate "prepare statement" configuration option is enabled.) – Frédéric Mar 30 '16 at 22:33