Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7980681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:09:01+00:00 2026-06-04T10:09:01+00:00

I need to convert this SQL query to nhibernate declare @i int set @i=2

  • 0

I need to convert this SQL query to nhibernate

declare @i int set @i=2
while (@i>0)
begin 
insert into #tmp_table3 (id , descr , RangeType , createdate )
select  * from AgeRanges as ar where AgeRangeID in (
select AgeRangeID as id from AgeRangeDetails where  agerangeid in
(select AgeRangeID from agerangedetails group by AgeRangeID having COUNT(AgeRangeID)=2)  
and agestart =(select AgeStart from #tmp_table2 where id=@i)
and AgeEnd = (select AgeEnd from #tmp_table2 where id=@i)
and Payment = (select Payment from #tmp_table2 where id=@i)
group by AgeRangeID)
and AgeRangeType=0
and AgeRangeID<>5 
set @i=@i-1
end
select id from #tmp_table3 where id in
(select id from #tmp_table3 group by id having COUNT(id)=2) group by id

can someone help me to do this.
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:09:02+00:00Added an answer on June 4, 2026 at 10:09 am

    This is quite a custom bit of SQL, it has a while loop, tmp tables and variables. For this reason you are only going to be able to either create a Stored Procedure or use a named query.

    a) create a Stored procedure and call it using:-

    session.CreateSqlQuery("exe sp_name")...
    

    more details…

    b) create a named query in mapping and call it like this:-

    session.GetNamedQuery("MyNamedQuery")...
    

    more details…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to convert this sql query to nhibernate criterion language... How can I do
I need to convert this for loop to a do while: for (int i
I'm having a hard time with this SQL Query. I need to convert this
I am trying to convert this sql into my LINQ query and am having
I need to convert this SQL Query to LINQ Query, also I need to
I need to convert a string like this: A &#039;quote&#039; is <b>bold</b> into: A
i need Sql query Convert Table1 to Table2 select Count(Page) as VisitingCount,CONVERT(VARCHAR(5),Date, 108) as
I have a SQL Server query that I need to convert to MySQL. I've
I am trying to convert the following SQL into NHibernate: SELECT * FROM dbo.Customer
this is my simple query written in ms sql server... now i need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.