Sql localDb Slow load data on standby mode [duplicate] - sql-server

I'm using SQL Server 2012 Express LocalDB. Instances seem to stop automatically after 10 minutes if there is no activity on them. Is there a clean way to keep an instance running forever?

The timeout is configurable via T-SQL with 'user instance timeout' option:
sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'user instance timeout', 5;
GO
The timeout is expressed in minutes and has a maximum value of 65535. I'm pretty sure you need to restart the instance after setting it. And don't try setting it to 0, it will just make the instance shut down immediately after starting, which will make it hard to set the value back to something useful :-).
Source: this BOL article containing other useful information on User Instances that are applicable to LocalDB instances as well.
Final Remark
If you need something that's always running and starts whenever a computer starts you might just consider using regular, service-based, instance of SQL Server Express.

Here is how to do Krzysztof Kozielczyk's answer from the command line.
Start the localdb instance.
C:\> sqllocaldb start v11.0
LocalDB instance "v11.0" started.
Get the server path, which is the Instance pipe name.
C:\> sqllocaldb info v11.0
Name: v11.0
Version: 11.0.3000.0
Shared name: IIS_DB
Owner: DESKTOP-AAAT5QS\bigfo
Auto-create: Yes
State: Running
Last start time: 2/17/2016 12:06:43 PM
Instance pipe name: np:\\.\pipe\LOCALDB#SH9D87FB\tsql\query
Run an SQL command on that server.
C:\> sqlcmd -S np:\\.\pipe\LOCALDB#SH9D87FB\tsql\query
1> sp_configure 'show advanced options', 1;
2> GO
Configuration option 'show advanced options' changed from 1 to 1.
Run the RECONFIGURE statement to install.
1> RECONFIGURE;
2> GO
1> sp_configure 'user instance timeout', 5;
2> GO
Configuration option 'user instance timeout' changed from 5 to 5.
Run the RECONFIGURE statement to install.
1> RECONFIGURE;
2> GO
> exit

Related

Docker container SQL Server with Access database engine

I'm new to docker and I love the implementation of it since
I wont suffer with auto running with SQL Server now which eat up my
precious MEMORY.
Though when trying to run a code to allow "import" data's from a "Access.mdb" file
using MS Access Database Engine but I got stuck with it..
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0',N'AllowInProcess', 1
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0',N'DynamicParameters', 1
I already installed the MSAccessDatabaseEngine in my PC (not in docker) and when I ran it
the error is:
A severe error occurred on the current command. The results, if any, should be discarded.
So I think it should be installed inside the container, my question is... is there anyway around to install this one together with the SQL Server container?
Cheers!

SQL Server 2012 tells me Agent XPs component is turned off but SQL Agent is running

I have a very strange situation on SQL Server that I cannot fathom out.
Environment : SQL Server 2012 SP3 CU3 running on a 2 node Windows 2008 R2 cluster
In SQL Server Management Studio\Management\Maintenance Plans\ I am unable to create or edit existing plans.
I receive the error:
'Agent XPs' component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Agent XPs' by using sp_configure. For more information about enabling 'Agent XPs', see "Surface Area Configuration" in SQL Server Books Online. (ObjectExplorer)
Checking around that error I expected the following config was going to be required.
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXEC sp_configure 'Agent XPs', 1;
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
However, I noticed that SQL Agent was already running so I thought I would also check existing config options for 'Agent XPs'
What was interesting was that config_value = 0, run_value = 1 where I was expecting config_value = 1, run_value = 1.
I thought I'd try the sp_configure solution to 'force' the config but when I ran it (step by step), the first RECONFIGURE statement just hung and indeed when it ran I could not even run an sp_who2 to see if it was blocking or being blocked.
The only way I could kill the RECONFIGURE was to close the query window which cancelled it. I therefore am unable to run EXEC sp_configure 'Agent XPs', 1 as the required RECONFIGURE cannot be run.
After a failover of the cluster, the config settings for 'Agent XPs'
remains at config_value = 0, run_value = 1.
Has anyone got any ideas as to how to fix it?
I stumbled across an internet post with a similar issue and that contained a nugget of information that allowed me to ultimately fix the issue.
I documented the case over at SQLServerCentral
https://www.sqlservercentral.com/Forums/1927277/SQL-Server-2012-tells-me-Agent-XPs-component-is-turned-off-but-SQL-Agent-is-running

Can I do "Local" System calls using query?

I'm currently on a host(A), connecting to a MSSQL database on server(B).
When I do a System call, such as
EXEC xp_cmdshell 'Systeminfo' GO
from within MS SQL 2008 it always returns me system information from the client(A) I'm currently running my SQL management tool on.
Is there a possibility to run System calls that will return me information from the server(B)?
I have since asking this question rebooted, and tried all the steps again:
1. Turn off local server
2. Connect to external server
3. Turn on XP_CMDSHELL command for the external server using
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1;
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
And then just run
EXEC xp_cmdshell 'Systeminfo';
GO
Weird that it works now,because I couldn't get it to work past weeks.

How to prevent SQL Server LocalDB auto shutdown?

I'm using SQL Server 2012 Express LocalDB. Instances seem to stop automatically after 10 minutes if there is no activity on them. Is there a clean way to keep an instance running forever?
The timeout is configurable via T-SQL with 'user instance timeout' option:
sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'user instance timeout', 5;
GO
The timeout is expressed in minutes and has a maximum value of 65535. I'm pretty sure you need to restart the instance after setting it. And don't try setting it to 0, it will just make the instance shut down immediately after starting, which will make it hard to set the value back to something useful :-).
Source: this BOL article containing other useful information on User Instances that are applicable to LocalDB instances as well.
Final Remark
If you need something that's always running and starts whenever a computer starts you might just consider using regular, service-based, instance of SQL Server Express.
Here is how to do Krzysztof Kozielczyk's answer from the command line.
Start the localdb instance.
C:\> sqllocaldb start v11.0
LocalDB instance "v11.0" started.
Get the server path, which is the Instance pipe name.
C:\> sqllocaldb info v11.0
Name: v11.0
Version: 11.0.3000.0
Shared name: IIS_DB
Owner: DESKTOP-AAAT5QS\bigfo
Auto-create: Yes
State: Running
Last start time: 2/17/2016 12:06:43 PM
Instance pipe name: np:\\.\pipe\LOCALDB#SH9D87FB\tsql\query
Run an SQL command on that server.
C:\> sqlcmd -S np:\\.\pipe\LOCALDB#SH9D87FB\tsql\query
1> sp_configure 'show advanced options', 1;
2> GO
Configuration option 'show advanced options' changed from 1 to 1.
Run the RECONFIGURE statement to install.
1> RECONFIGURE;
2> GO
1> sp_configure 'user instance timeout', 5;
2> GO
Configuration option 'user instance timeout' changed from 5 to 5.
Run the RECONFIGURE statement to install.
1> RECONFIGURE;
2> GO
> exit

How do I set a SQL Server script's timeout from within the script?

I have a large script file (nearly 300MB, and feasibly bigger in the future) that I am trying to run. It has been suggested in the comments of Gulzar's answer to my question about it that I should change the script timeout to 0 (no timeout).
What is the best way to set this timeout from within the script? At the moment I have all of this at the top of the script file in the hopes that one of them does something:
sp_configure 'remote login timeout', 600
go
sp_configure 'remote query timeout', 0
go
sp_configure 'query wait', 0
go
reconfigure with override
go
However, I'm still getting the same result and I can't tell if I'm succeeding in setting the timeout because the response from sqlcmd.exe is the world's least helpful error message:
Sqlcmd: Error: Scripting error.
Your solution - Add GO every 100 or 150 lines
http://www.red-gate.com/MessageBoard/viewtopic.php?t=8109
sqlcmd -t {n}
Where {n} must be a number between 0 and 65535.
Note that your question is a bit misleading since the server has no concept of a timeout and therefore you cannot set the timeout within your script.
In your context the timeout is enforced by sqlcmd
I think there is no concept of timeout within a SQL script on SQL Server. You have to set the timeout in the calling layer / client.
According to this MSDN article you could try to increase the timeout this way:
exec sp_configure 'remote query timeout', 0
go
reconfigure with override
go
"Use the remote query timeout option to specify how long, in seconds, a remote operation can take before Microsoft SQL Server times out. The default is 600, which allows a 10-minute wait. This value applies to an outgoing connection initiated by the Database Engine as a remote query. This value has no effect on queries received by the Database Engine."
P.S.: By 300 MB you mean the resulting file is 300 MB? I don't hope that the script file itself is 300 MB. That would be a world record. ;-)

Resources