Ошибка 701 sql

Search code, repositories, users, issues, pull requests…

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Microsoft SQL Server throws error 701 if there is any insufficient memory issue.

Here at Bobcares, we have seen several such SQL related issues as part of our Server Management Services for web hosts and online service providers.

Today we’ll take a look at the cause for this error and how to fix it.

Why does Microsoft SQL Server error 701 occur

Now let’s see in detail why actually does this error occurs.

During any bulk data load or during any memory-intensive operations, the database instance might face some SQL Server memory issues.

We may also come across some insufficient memory issue while trying to execute numerous queries on large data sets at the same time in SQL Server.

In such cases, SQL will throw 701 errors. Here is an image of the error message ‘Application Log error 701’

Microsoft SQL Server Error 701

Mainly this error occurs if SQL Server is running out of memory and has no more memory available to allocate to its transactions.

How we fix Microsoft SQL Server error 701

Now let’s see what solution our Support Engineers provide.

If we are facing any memory issue in the SQL server then we first need to troubleshoot the issue and find the root cause for the memory consumption.

Here is the step by step process to find the cause of memory consumption and possible solutions.

1. SQL Server instance running on a dedicated server

First, make sure that the SQL Server instance is running on a dedicated server and not with other applications.

In case, if other applications are also using the database server, then make sure they are not eating most of the memory.

If other applications are taking more memory then migrate it to other database servers. If it is not possible to migrate then allocate the maximum memory value to your SQL Server instance. You can do it using SQL Server Management Studio.

  • First, right-click on SQL Server Instance and select properties.
  • The server properties window will appear on the screen, now click on the “memory” tab from the left side pane.
  • You can change the value of min and max server memory as per your need in the right-side panel.

2. Check server memory configuration

Secondly, check the server memory configuration. Here are the SQL Server memory configuration parameters that we need to check:

max server memory
min server memory
min memory per query

If there is any difference in the value of max server memory and min server memory then increase the value of ‘max server memory’.

3. Check the workload

Check the workload in terms of the number of concurrent sessions. Also, check the SQL Server transactions that are using huge memory values. Make a report on them and try to optimize such that it will take minimum memory.

4. Find Index usages for long-running queries

Find out index usages for long-running queries. We need to do this because without proper indexing your system DISK I/O increases and it directly affects your memory.

5. Run DBCC commands

We also recommend running the below DBCC commands to free several SQL Server memory caches.

DBCC FREESYSTEMCACHE
DBCC FREESESSIONCACHE
DBCC FREEPROCCACHE

6. The output of the DBCC MEMORYSTATUS command

Getting the output of DBCC MEMORYSTATUS command is also a great way to look into the memory status.

7. Performance monitor counters for memory

Start collecting performance monitor counters for memory. Performance counters like the value of SQL Server: Buffer Manager\Buffer Cache Hit Ratio, SQL Server: Memory Manager, and Page Life Expectancy will be of great help in identifying memory pressure on the SQL Server system.

Then you can analyze these counters and decide whether the issue is coming during some specific operations or system is continuously facing memory pressure.

Based on these analyses, you can choose to either increase the system memory, increase the SQL Server memory allocation or reschedule some of the memory specific transactions to the off-hours when the load is minimum on the system.

[Need any further assistance in fixing SQL errors? – We’re available 24*7]

Conclusion

In short, SQL Server Memory pressure or insufficient memory issue can be raised due to huge data load or other memory-intensive operations that lead to a 701 error in the SQL server.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

Error 701 There is insufficient system memory to run this query

Download PDF

Error 701, “There is insufficient system memory to run this query,” is a common error message in SQL Server. This error indicates that the system does not have enough memory available to execute the query.

There are several reasons why this error may occur, including:

  • The query is too complex and requires more memory than is available.
  • The query is trying to process a large amount of data, and there is not enough memory to hold all the data in memory.
  • There are other processes running on the system that are using a lot of memory, leaving little available for SQL Server.

To address this error, you can try several different strategies, depending on the specific cause of the error:

  • If the query is too complex, try simplifying it by breaking it down into smaller queries or using more efficient algorithms.
  • If the query is processing a large amount of data, try using a cursor or other techniques to process the data in smaller batches.
  • If other processes are using a lot of memory, try reducing their memory usage or increasing the amount of memory available to SQL Server.

It is also important to monitor the memory usage of SQL Server and the system as a whole, so you can identify and address any potential memory constraints before they cause errors like 701.

In conclusion, Error 701, “There is insufficient system memory to run this query,” is a common error in SQL Server that can be caused by a variety of factors. By understanding the potential causes of this error and using the strategies described above, you can help prevent and address this error in your database.

SteveStedman5

Steve and the team at Stedman Solutions are here for all your SQL Server needs.

Contact us today for your free 30 minute consultation..

We are ready to help!

Today I am going to discuss SQL Server memory issues that your database Instance might face during bulk data load or during any memory intensive operations. You may also face insufficient memory issue when you try to execute numerous queries on large data sets at the same time in SQL Server. In such circumstances, SQL Server throws error 701 or error 802 with error text “There is insufficient system memory to run this query.” Full error descriptions for both error codes are given below.

Error 701, Severity: 17, State: 193.
There is insufficient system memory to run this query.

Or

Error 802, Severity: 17, State: 20
There is insufficient memory available in the buffer pool.

Error 701 or Error 802: Root Cause

If SQL Server is running out of memory and has no more memory available to allocate to its transactions then it will generate SQL Server memory error 701 or error 802. SQL Server Memory pressure or insufficient memory issue can be raised due to huge data load or other memory intensive operations.

We should check DBCC MEMORYSTATUS output to get latest snapshot of current memory status of the SQL Server. This command is very useful in troubleshooting memory issues in SQL Server. You might even have failed to run this DBCC command because system does not have enough memory. You need to reduce some memory pressure by stopping or killing some processes and then try to run this command to gather in depth information about SQL Server memory state.

The transaction that failed due to memory pressure and generates error 701 or error 802 might be or might not be the cause of this error. We should analyze the trends to reach on any conclusion.

Solution

There are mainly two reasons behind getting SQL Server memory issues for most of the SQL Server systems. Either your server has less memory to handle the current day to day workload or you are running some of the adhoc transactions that will require more memory for their execution like huge bulk data load, complex reports etc. If your SQL Server is running with insufficient memory during day to day activities then you should seriously evaluate the total workload and propose optimum memory size that can handle your current workload.

If you are planning to run any heavy ad hoc transaction then you should temporary increase the memory that can handle the transaction smoothly or you should run such transactions on a server that are built to handle such loads. You should also consider to reduce the batch size that is optimum for your system.

SQL Server is memory intensive application. We need to plan memory sizing for a server after proper evaluation of server state and overall load that will run on that SQL Server instance. But if you are facing memory issue on one of your SQL Server then first we need to troubleshoot it and find the root cause of this memory pressure. Here I am giving you step by step method to find the actual culprit that are causing the memory issue and possible solutions that can reduce some memory overheads.

First Make sure your SQL Server instance is running on dedicated server and not with other applications. If other applications are also using your database server then make sure they are not eating most of the memory. And, If most of the system memory is taken by other applications then you need to seriously think about migrating those application from this database server.

If you cannot migrate these applications to another server then workaround for such issues are to allocate the maximum memory value to your SQL Server instance. You can do it either by using sp_configure or using GUI. Read attached article to change max memory value for your SQL Server instance.

  • Understanding SQL Server Memory Allocation and Role of MIN/MAX Server Memory Configuration

Next thing you should check is the server memory configuration. Check below SQL Server memory configuration parameters:

  • max server memory
  • min server memory
  • min memory per query

Notice any unusual settings and fix them as necessary. All above three options have been covered in detain in above attached article.

Now, check the workload in terms of number of concurrent sessions, currently executing queries along with their memory grants. You should also focus on SQL Server transactions that are seeking huge memory values. Look at the transactions and gather a report for high memory intensive operations. Evaluate them and if possible optimize them so that they can take minimum memory.

  • Understanding Memory Wait type Resource_SEMAPHORE and how to fix it?

You can also run below DBCC commands to free several SQL Server memory caches. This will also help you and make some relief for your current running transactions but in longer run it will not help if your system will need more memory to proceed the transactions.

  • DBCC FREESYSTEMCACHE
  • DBCC FREESESSIONCACHE
  • DBCC FREEPROCCACHE

Another effective way to look in to memory status is by getting the output of DBCC MEMORYSTATUS command. You would get a good starting point to look in to culprit memory consumers.

We can also start collecting performance monitor counters for memory. Perfmon counters like the value of SQL Server: Buffer Manager\Buffer Cache Hit Ratio, SQL Server: Memory Manager and Page Life Expectancy will be very helpful in identifying memory pressure on SQL Server system. Analyze the trend for these counters and then decide whether issue is coming during some specific operations or system is continuously facing memory pressure.

Based on these analyses you can choose to either increase the system memory, increase the SQL Server memory allocation or reschedule some of the memory specific transactions to the off hours when load is minimum on the system. You can also reduce the batch size of the transaction to reduce the memory pressure. This will be certainly helpful in troubleshooting memory issues.

It is not necessary that your transactions are poorly designed always that is why SQL Server is taking lot of memory to process it. Sometimes even our systems on which SQL Server runs might have problem that end up with memory pressure. So you should consider all these points while fixing any performance issue.
I hope you like this article. Please follow us on our Facebook page and Twitter handle to get latest updates.

Read More:

  • 4 Usages of DBCC SQLPERF in SQL Server
  • Manage Transaction Log File during Bulk Data Load
  • How to Improve Bulk Data Load Performance?
  • Overview of SQL Server Performance Tuning
  • Identify Disk Bottleneck in SQL Server using Perfmon Disk Counters
  • Author
  • Recent Posts

Manvendra Deo Singh

I am working as a Technical Architect in one of the top IT consulting firm. I have expertise on all versions of SQL Server since SQL Server 2000. I have lead multiple SQL Server projects like consolidation, upgrades, migrations, HA & DR. I love to share my knowledge. You can contact me on my social accounts for any consulting work.

Manvendra Deo Singh

Summary

Article Name

SQL Server Error 701: There is Insufficient System Memory to Run this Query

Description

Today I am going to discuss SQL Server memory issues that your database Instance might face during bulk data load or during any memory intensive operations. In such circumstances, SQL Server throws error 701 or error 802 with error text “There is insufficient system memory to run this query.”

This question actually seems to come up every so often here. Mark has the correct (and most commonly employed) answer, but let me try to add what I can to make this clearer.

The error message is a little misleading. SQL Server tells you that it doesn’t have enough memory to run the query, but what it really means is that it doesn’t have enough memory to parse the query.

When it comes to running the query, SQL Server can use all it wants — gigabytes if necessary. Parsing is another story; the server has to build a parse tree and there is only a very limited amount of memory available for that. I’ve never found the actual limit documented anywhere but for a typical batch full of INSERT statements, it can’t handle more than a few MB at a time.

So I am sorry to tell you this but you cannot make SQL Server execute this script exactly as it is written. No way, no how, doesn’t matter what settings you tweak. You do, however, have a number of options to work around it:

Specifically, you have three options:

  1. Use GO statements. This is used by SSMS and various other tools as a batch separator. Instead of a single parse tree being generated for the entire script, individual parse trees are generated for each segment of the batch separated by GO. This is what most people do, and it is very simple to still make the script transactionally-safe, as others have demonstrated and I won’t repeat here.

  2. Instead of generating a massive script to insert all of the rows, keep the data in a text file (i.e. comma-separated). Then import it using the bcp utility. If you need this to be «scriptable» — i.e. the import needs to happen in the same script/transaction as the CREATE TABLE statement, then use BULK INSERT instead. Although BULK INSERT is a non-logged operation, believe it or not, it can still be placed within a BEGIN TRAN / COMMIT TRAN block.

  3. If you really, really want the INSERT to be a logged operation, and don’t want the insertions to happen in batches, then you can use OPENROWSET to open up a text file, excel file, etc. as an ad-hoc «table», and then insert this into your newly-created table. I’m normally loath to ever recommend the use of OPENROWSET, but as this is clearly an administrative script, it’s not really a major problem.


Previous comments suggest that you’re uncomfortable with #1, although that may just be because of an incorrect assumption that it can’t be done in a single transaction, in which case see Thomas’s answer. But if you’re dead-set on going another way, I suggest going with #2, creating a text file and using BULK INSERT. An example of a «safe» script would be:

BEGIN TRAN

BEGIN TRY

    CREATE TABLE MyTable (...)

    BULK INSERT  MyTable
    FROM 'C:\Scripts\Data\MyTableData.txt' 
    WITH (
        FIELDTERMINATOR = ',',
        ROWTERMINATOR = '\r\n',
        BATCHSIZE = 1000,
        MAXERRORS = 1
    )

    COMMIT

END TRY

BEGIN CATCH

    ROLLBACK

END CATCH

Hopefully this helps put you on the right track. I’m pretty sure this covers all of your available «in the box» options — beyond these, you’d have to start writing actual application programs or shell scripts to do the work, and I don’t think that level of complexity is really warranted here.

Понравилась статья? Поделить с друзьями:
  • Ошибка 7009 превышение времени
  • Ошибка 7002 kyocera 6230
  • Ошибка 700026 sinumerik 808d
  • Ошибка 7 zip ошибка контрольной суммы crc
  • Ошибка 7009 windows 10 как исправить