Sql Server 2005 - cannot obtain a LOCK resource - sql

The observed problem and error message is:
The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users.Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions
Environment: SQL Server 2005 Standard edition on Windows server 2003 Standard edition. Virtualized on a VM - with 8 GB RAM
Automatic applications are processing data - reading raw data and writing results to the database. These applications get the error message and they crash on it. (There are also database backup and index maintenance jobs scheduled.)
The same error was never observed on a similar system with sql server 2005 enterprise edition and windows 2003 enterprise edition.
I have already searched the web and found some answers. But e.g.
SQL Server cannot obtain a LOCK resource at this time - What to do?
was not helpful in my case
One source suggested to check:
SELECT request_session_id, COUNT (*) num_locks
FROM sys.dm_tran_locks
GROUP BY request_session_id
ORDER BY count (*) DESC
One session came up with 10.
The memory and lock settings are both in the default settings.
My current idea is to purge most of the data which is old and can be removed.
Does anybody have any other ideas how to deal with the lock resource problem? What exactly is its cause? Does SQL server standard edition allow less resources - is the problem related to the sql server version? How to fix the issue?

The autoshrink function had multiple locks on the database catalog.
The autoshrink also fragmented the primary key of a table after rebuilding the primary key.
Switching off the autoshrink function has solved the problem

Related

Procedure stats getting cleared very often

Recent days, in our organisation, we are facing with a strange issue.
Our SQL Server has enough memory(256 GB) and CPU cores. There is no memory pressure(outcome of dm_os_sys_memory is "Available physical memory is high").
Only problem is, the procedure stats sys.dm_exec_procedure_stats is getting cleared very often. Stats doesn't stay even for an hour.
The reason why we need the stats is, it is being collected on daily basis with the help of the DMV dm_exec_procedure_stats. And, our SQL Developers used to do optimization on stored procedures, and once it is done, to know the effectiveness of the tuning activity, a comparison is being done between the collected historical stats and the current one.
Since, the procedure stats is not staying on the cache, we are not able to set any benchmark.
Kindly suggest some solutions.
Version: Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64) Enterprise Edition: (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600: )
There are a number of ways that the cache can get cleared from Overall instance config changes to Db changes through to using recompile in procedures.
This link gives a good lead on what may be causing the issue but I think you are going to have to do some investigating.
https://www.sqlskills.com/blogs/glenn/eight-different-ways-to-clear-the-sql-server-plan-cache/

Migration from SQL Server 2000 to 2012 without Outage

I am working on a project which is migrating some legacy SQL Server 2000 instances to SQL Server 2012. As you read word legacy, these databases are used by some VB based desktop applications. It has around 4000+ users and application is rated GOLD (means it has to be up 24x7)
Summary again
Desktop exe Installed VB applications -> SQL Server 2000
Target State
Desktop exe Installed VB applications -> SQL Server 2012
Application uses a config file that contains SQL Server details that it connects to. So once data move to new SQL Server, this config file needs to be changed with new server details.
I have been told that SQL Server 2000 can't migrate directly. It should first go to SQL Server 2008 and then SQL Server 2012. Please correct if this is not right understanding?
My problem is around Implementation Plan for this task in production. I can't move all users in one go means I would be migrating 100 users first and then few other hundreds and finally all left. Which means some users might start using SQL Server 2012 while other still working with SQL Server 2000. The reason I don't want everything in one go because it's too risky in case of any glitch and because application has to be up 24x7 it's not possible to bring down the applications and update config files on each user's desktop.
But if I allow 2000 and 2012 running together (say 1 week until all users move), it will make these databases out of sync and I don't think they can be merged later because both databases may be having same primary keys assigned to different data.
I can't bring the application down and take 4 hours outage to allow all users move to new databases in one shot because application has to be up 24x7.
Can any one recommend any approach that generally companies take to migrate SQL Server without outage like I stated above with keeping data consistency?
The easiest way to handle this is to create a new 2012 instance and create a database from a restore of the 2000 database. Then have replication between the 2 databases so that changes in either database will be published to the other that way your primary keys stay in sync. You will have to be down for a short period where you do the backup and restore to move all the data but assuming the 2 servers are co-located then it should only be a matter of minutes. Then once all your users have been migrated just turn off the 2000 server.

Can I mirror SQL server enterprise to standard?

I want to setup mirroring between 2 copies of SQL server. The primary box is SQL server enterprise edition.
Can I mirror it to a SQL server standard edition? The purpose is to save a metric ton of money.
From Books Online:
The two partners, that is the principal server and mirror server, must be running the same edition of SQL Server. The witness, if any, can run on any edition of SQL Server that supports database mirroring.
That being said, it is possible to set it up as long as you use TSQL commands and not the GUI. I would never recommend it, but it is possible, as long as you guarantee you're not using any Enterprise features. More warnings HERE and HERE.
Last edit - apparently this has been completely blocked in SQL 2012. Looks like you're out of luck.

SQL Server 2008 Web edition

My company is planning to migrate it's intranet/internet based ERP to the latest form of MS SQL Database available.
Presently we are using SQL Server 2000 Professional.
And we are planning to shift to SQL Server 2008 Web edition.
Please tell me whether this is the right step and whether it is feasible or not.
Thank you in advance.
"Please tell me whether this is the right step " - that's something you and your company need to decide.
It is feasible, and in the majority of cases straight forward.
Your first step should be to run the Microsoft SQL Server 2008 Upgrade Advisor
Microsoft SQL Server 2008 R2 Feature Pack contains the Microsoft SQL Server 2008 R2 Upgrade Advisor
Formulate and test a rollback plan
Determine your upgrade window and acceptable downtime.
Ensure database consistency: Run DBCC CHECKDB on databases to be upgraded to ensure that they are in a consistent state before performing the upgrade.
Back up all important files: Back up all SQL Server databases from the instance to be upgraded (including master, model and msdb), data and transaction log files, as well as any application files, script files, extract files, etc. so that you can completely restore them in the event of a failure.
It's both feasible and easy. The path from one version of SQL Server to another is usually pretty simple. Do you have any special stored procedures or reports generated in SQL Server that need to be rewritten/re-imported?
As far as right step - the question is, Why? If it's working, do you really need to mess with it?
If it's for intranet (some app for your internal usage) then consider using SQL 2008 Express edition. It's free and you can use it as an instance running along the full 2000 version. That way you will have some extra features from the full version.
But you have to know that applications running on SQL 2000 may not work on 2008 and they are even more probable not to work on 2008 R2.

Partial import of Sql server 2005 database for local developement

So at work, my team is using a central SQL server 2005 database server for integration testing and I want to move to testing on my local database. The only problem is that the central database is in excess of 10 Gb.
I am interested in importing the data objects and a rows for each table to ensure I can be up and running. Can you guys advise me on how I can do this?
I have VS 2008 professional and SQL Server management studio express. Would I need VS 2008 database edition?
Thanks
-Venu
EDIT : I will try logging into the central database server and seeing if the host machine has better tools. Thanks kpollock, I didn't think of that.
Both 2005 and 2008 Express editions have 4 gb limitation.
Have you thought about making a db copy on central server and dealing with it (just restore it into new db with other name)?
See also BACKUP and RESTORE in SQL Server -- Full Backups
Looks like an SSIS job to me - which I think Express version of Management Studio doesn't have.
Or you could do it in C# calling Stored procs on the source database to extract the data if that's where your skills lie. (this is how I would do it as I think it's more widely comprehensible - but that's just my opinion).
If the database is live and new data comes in all the time perhaps you could set up the schema and reference data only then use replication to get the new data as it comes in (if you think that will get you a representative sample).
You will have to code up the sample extraction based upon an understanding of the schema - i.e. ensure you get a full set of linked records (e.g detail records for orders and all lookups e.g. customer, addresses, etc.).