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 8835257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:13:08+00:00 2026-06-14T09:13:08+00:00

When I execute the following SQL in the management studio the query returns the

  • 0

When I execute the following SQL in the management studio the query returns the expected result:

SELECT MAX(ID) FROM table WHERE field = value;

However when my client application (WinForms) execute’s this SQL in the middle of a Transaction the query Times Out without returning a value. I suspect this is because the Transaction includes other SQL statements which are adding to / amending the same ‘table’.

How do I work around this?

  • 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-14T09:13:09+00:00Added an answer on June 14, 2026 at 9:13 am

    “SELECT MAX(ID)” is an aggregate function and will do a lot of locking on the table – a shared read lock can potentially be taken on all the records in the table, certainly on all those that match your criteria, and others depending on whether row or page locks are used. If there is an outstanding write lock on any of these records that the MAX wants to lock, then the MAX will time out. You need to understand what other locks are in place at the same time. If you are using SQL Server, then you can use SQL Profiler to get a trace which will show you all the locks on that table, including locks from other transactions.

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

Sidebar

Related Questions

Given the following scenario: A select statement is executed from Sql Server Management Studio
I am using SQL Server 2008 management studio to execute the following SQL statements,
I'm trying to execute the following SQL: SELECT * FROM Table2 INNER JOIN (SELECT
I am trying to execute following query: Insert into pligg_links_temp select * from pligg_links
I am trying to execute the following SQL query using MS SQL Server Management
I executed the following Query in SQL Server Management studio 2005 and I did
I try to execute the following SQL-Statement (in my Java-application): SELECT * FROM Tbl_Job
Assuming A.sql contains the following code, then second Select query won’t be executed due
I get the following error when I execute SP in SQL Server 2008 Management
I'm using SMO to execute a batch SQL script. In Management Studio, the script

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.