Jim Rogers

Lives in Baton Rouge, LA, with two dogs, one cat, and one lovely wife. I'm a lead developer for GCR Incorporated.

Katrin and Jim

Month List

Speaking on Azure

by jim Mar 28, 2011 11:00 AM

I’ll be speaking at the upcoming Baton Rouge .NET User Group (BRDNUG) meeting on April 13th. The topic: An Introduction to Windows Azure.

More information is available at brdnug.org. (That link will likely be broken soon – try the base site at brdnug.org.)

My employer Antares Technology Solutions is sponsoring the event. Drop by if you’re in the area!!

Tags:

Code

Running NHibernate queries in management studio

by Jim Mar 17, 2011 5:33 PM
If you watch your NHibernate-generated queries go by in SQL Profiler, you’ll see a whole lot of SQL that looks like this:
declare @p1 int
set @p1=11
exec sp_prepexec @p1 output,N'@p0 varchar(8000),@p1 ...
SELECT TOP (@p1) this_.ProjectId as ProjectId78_0_, ...
',@p0='jimrogers',@p1=10,@p2='jimrogers',@p4=10
select @p1
But if you try to paste that into SQL Management Studio and run it, you get this error:
Msg 8179, Level 16, State 2, Procedure sp_prepexec, Line 1
Could not find prepared statement with handle 11.
Getting the query to run is simple enough – just comment out or delete the second line:
declare @p1 int
--set @p1=11
exec sp_prepexec @p1 output,N'@p0 varchar(8000),@p1 ...
SELECT TOP (@p1) this_.ProjectId as ProjectId78_0_, ...
',@p0='jimrogers',@p1=10,@p2='jimrogers',@p4=10
select @p1