Microsoft SQL Server 2008 Express decreasing memory usage - sql-server-2008-express

I have a virtual machine running windows 2008 standard R2 sp1 and Forefront TMG 2010. TMG 2010 also installs SQL Server 2008 Express for logging activities. According to perfmon SQL Server Express is using about 1 gb of ram. I have tried to decrease buffer pool max memory usage to 100mb (below code), restarted sql process but sometime later it goes up again about 1gb memory usage. SQL is just used for logging TMG activities and not critical so I want to decrease memory footprint of total SQL usage. If it is possible with Microsoft implementation.
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'max server memory (MB)', 100
GO
EXEC sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE

Related

Azure - Enable/Disable database setting for security purposes

We have certain security requirements in order for our app to go live within our orgainisation.
We are using the Microsoft azure platform to host the application along with a Azure SQL server and database. To meet these security requirements, we need to configure settings on the server/database.
However we are running into issues using the default azure SQL server/database.
Here is an example. We need to "Disable 'clr enabled' option".
We have tried the following:
EXECUTE sp_configure 'show advanced options', 1;
RECONFIGURE;
EXECUTE sp_configure 'clr enabled', 0;
RECONFIGURE;
GO
EXECUTE sp_configure 'show advanced options', 0;
RECONFIGURE;
We run this in the T-SQL editor on the Azure platform, and receive the following:
Failed to execute query. Error: Statement 'CONFIG' is not supported in this version of SQL Server.
When we run the following, we see that is enabled.
SELECT name,
CAST(value as int) as value_configured,
CAST(value_in_use as int) as value_in_use
FROM sys.configurations
WHERE name = 'clr enabled';
How to we update these settings?
thanks.
sp_configure (Transact-SQL) is not supported in Azure SQL database:
We can not run the sp_configure statements. But sys.configurations (Transact-SQL) table is supported.
We can see the default value is 1 for clr enabled.
And like #Larnu said, CLR is also not supported: Resolving Transact-SQL differences during migration to SQL Database.
Ref this question: Does or does not SQL Azure support CLR assemblies?
Just for now, we can not change this settings in Azure SQL database.
HTH.

Schedule query in SQL Server 2014 Management Studio

I am trying to schedule a SQL query in SQL Server 2014 Management Studio.
For some reason I am unable to find SQL Server Agent (i.e. to expand Jobs to create Schedule).
Is there a new way to schedule SQL query on SQL Server 2014?
Thanks
You can use Windows Task Scheduler to run your SQL query.
Follow below link to creation and deployment of task.
Click here to create windows task
SQL Server Express does not include SQL Server Agent. Editions higher than that (such as Standard, Enterprise/Developer) do.
If your edition supports SQL Server Agent, make sure it is installed.
If it is installed, you may need to configure it before you see it show up as available in SSMS.
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Agent XPs', 1;
GO
RECONFIGURE
GO
source
This is for the most basic configuration, without regard to permissions and such. For that, it's probably worth reading this short overview.

SQL Server not releasing memory after execution completes

I am using SQL Server 2014 Developer edition.
SQL Server is running on server and it's occupied around 60 GB memory while execution and after completion of execution it's not releasing it.
Please suggest on this.
I want to reduce it to normal.
Why you might want to limit SQL Server memory
It's common for SQL server to have several instances on a machine which is not a dedicated SQL server machine, but where SQL Server embedded or LocalDB is installed as part of an operating system component or as part of an application.
In these circumstances it is appropriate to allocate memory to each instance so they don't tread on each other's toes.
In addition, some applications make heavy use both of a database as well as memory and processor intensive application processing. Where there is a lot of transfer to and from the database it can make sense to locate the DB on the same machine as the application to reduce the IO cost, as they can then use a shared memory connection. In this case, again, you will have to allocate how much memory SQL server is allowed to use.
Development machines are a perfect example of this - typically you will have an installation of SQL Server development edition, and in addition to that any database projects will spin up an instance of SQL Server LocalDB.
How to do it
For your Dev machine you want to keep this value relatively low. I’d suggest 512 MB, but if you feel that’s too low 1024 MB shouldn’t be a problem
To reduce SQL Server memory usage you can run the following SQL:
EXEC sys.sp_configure N'show advanced options', N'1' ;
RECONFIGURE WITH OVERRIDE;
EXEC sys.sp_configure N'max server memory (MB)', N'512';
RECONFIGURE WITH OVERRIDE;
EXEC sys.sp_configure N'show advanced options', N'0';
RECONFIGURE WITH OVERRIDE;
Reducing usage of the LocalDB instances is similar, you simply have to connect to each LocalDB instance and use the same commands.
For example, to set all LocalDB instances to use at most 256MB:
$MaxServerMemory = 256
#( & sqllocaldb info ) | %{
"Reconfiguring (LocalDB)\$_"
& sqlcmd.exe -E -S "(LocalDB)\$_" -Q "EXEC sys.sp_configure N'show advanced options', N'1' ;RECONFIGURE WITH OVERRIDE;EXEC sys.sp_configure N'max server memory (MB)', N'$MaxServerMemory';RECONFIGURE WITH OVERRIDE;EXEC sys.sp_configure N'show advanced options', N'0'; RECONFIGURE WITH OVERRIDE;" *>&1
""
}

SQL Query to import data from 50 Access ACCDB databases

I am new to SQL, so please forgive my ignorance. I downloaded the free version of SQL Server Express Edition 2014 and have a 32 bit machine. I'm using Microsoft SQL Server Mgmt Studio. I am trying to setup a process to either link to or import 50 Access tables that are in 50 individual Microsoft Access 2013 databases (updated weekly) into SQL. I currently do this in an Access 2013 db but I am trying to replace the process. I downloaded the free version of SQL Server Express Edition 2014 and have a 32 bit machine. I'm using Microsoft SQL Server Mgmt Studio on my PC. Below is the code I put together. however, this is the result in the message window:
Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.
Configuration option 'Ad Hoc Distributed Queries' changed from 1 to 1. Run the RECONFIGURE statement to install.
Msg 7403, Level 16, State 1, Line 8
The OLE DB provider "Microsoft.Jet.OLEDB.12.0" has not been registered.
I am a newbie so I would greatly appreciate no assumptions in knowledge. Thank you.
sp_configure 'show advanced options', 1;
RECONFIGURE WITH OVERRIDE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE WITH OVERRIDE;
GO
INSERT INTO TEST2.dbo.MyTest
SELECT * FROM OPENDATASOURCE(
'Microsoft.Jet.OLEDB.12.0',
'Data Source="D:\data\EXCEPT2.accdb"')...Testtbl;
GO
Turns out I had to run the below code to get the sql to work. I also had changed 'Microsoft.Jet.OLEDB.12.0', to 'Microsoft.Jet.ACE.12.0',
USE [master]
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
GO

Openrowset on SQL Server 2008 R2 installed in Windows 2008 64 bit machine

I'm trying to working with Openrowset on SQL Server 2008 R2 installed in Windows 2008 64 bit machine.When I execute the below query, i got an error like below.Please help me out.
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\01112012.xls;','SELECT * FROM [Sheet1$]')
ERROR:
Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.
Have you installed: ->Microsoft Access Database Engine 2010 Redistributable
This download will install a set of components that facilitate the transfer of data between existing Microsoft Office files such as Microsoft Office Access 2010 (*.mdb and .accdb) files and Microsoft Office Excel 2010 (.xls, *.xlsx, and *.xlsb) files to other data sources such as Microsoft SQL Server. Connectivity to existing text files is also supported. ODBC and OLEDB drivers are installed for application developers to use in developing their applications with connectivity to Office file formats.
To run OPENROWSET in 64 bit version of windows.
1- Install AccessDatabaseEngine_x64.exe (Restart is required).
2- If you are using SQL Management Studio, run Management Studio as administrator. If you don’t run it as an administrator account you will have this error (Cannot initialize the data source object of OLE DB provider "MICROSOFT.ACE.OLEDB.12.0" for linked server "(null)".
3- Run this command to configure your Database
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE with override;
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE with override;
GO
EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1
GO
EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1
GO
4- Don’t use ‘select * from sheet1$’ in OPENROWSET function. Try this code.
select * from OPENROWSET('MICROSOFT.ACE.OLEDB.12.0', 'Excel 12.0;HDR=YES;DATABASE=D:\test.xlsx', sheet1$)
If still you have (32 bit) error, try to restart your SQL service and check your C:\Windows\Temp and see do you have access to this directory or not.