Getting error when Executing sp_configure 'max server memory' - sql

When I want to set max server memory, I am getting the bellow error message:
The configuration option 'max server memory' does not exist, or it may
be an advanced option
sql query is as follow:
exec sp_configure 'max server memory', 1024
reconfigure

The error message is pretty clear, it's telling you that's an advanced option
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'max server memory', 1024;
GO
RECONFIGURE;
GO
You may want to read Server Memory Configuration Options

The error is telling you the problem here, it's an advanced setting and you haven't enabled them. A search would have led you to the documentation: Example A. Set the max server memory option to 4 GB.
:
The following example sets the max server memory option to 4 GB. Note
that although sp_configure specifies the name of the option as max
server memory (MB), the example demonstrates omitting the (MB).
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'max server memory', 4096;
GO
RECONFIGURE;
GO
Do you really want to set the Memory to 1GB though? That's nothing for SQL Server to "play" with; you're very likely going to have performance issues.

Related

Error while executing xp_readerrorlog using OPENROWSET in SQL Server - querying remote data sources

Can you please help me to fix this query?
SELECT
FROM OPENROWSET('SQLNCLI',
'Server=.;Trusted_Connection=Yes;',
'SET FMTONLY OFF;EXEC master.sys.xp_readerrorlog')
I get this error:
Msg 11519, Level 16, State 1, Procedure sys.sp_describe_first_result_set, Line 1 [Batch Start Line 12]
The metadata could not be determined because statement 'EXEC master.sys.xp_readerrorlog' invokes an extended stored procedure.
I have enabled Ad-Hoc Distributed Queries as well by using below query but getting same error.
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO
You cannot use OPENROWSET for an extended stored procedure. You could create a linked server
EXEC {Your Linked Server Name}.master.sys.xp_readerrorlog;
But you say you have 120 instances. (Quite why you don't have management software for so many, is another question...) So you are better off using Powershell to do this. For example
Get-SqlErrorLog
-Since LastMonth
-ServerInstance "your","Server","Instances","Here"
You would probably want other code to filter and group the results, but you haven't shown what you want.
For example you could do something like this
Get-Content "ServerInstances.txt"
| Get-SqlErrorLog -After "2022-09-16 10:00:00"
| Where Source -eq "Backup"

Getting A transport-level error when executing OPENROWSET

I'm trying to get data from a CSV file using OPENROWSET but I am encountering error:
"Msg 109, Level 20, State 0, Line 0
A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 0 - The pipe has been ended.)"
I used the query below
select *
FROM OPENROWSET(
'Microsoft.ACE.OLEDB.12.0',
'Text;Database=C:\Users\Public;HDR=Yes;FORMAT=Delimited(;)',
'SELECT * FROM [file.csv]'
)
I was able to get the query once when I used SELECT * but when I ran the query with the column names it caused the error above and now the query does not work even with SELECT * anymore
Try this
Open SSMS
Expand Server Objects > Linked Servers > Providers
Double click the provider (Microsoft.Jet.OLEDB.12.0)
UNTICK the "Allow inprocess" option
I had this come up today. I recently upgraded to 64-bit Excel on my system and noticed the OPENROWSET functionality broke. I downloaded and re-installed the engine and it seems to have fixed my problem.
You must use this config for sql server
SP_CONFIGURE 'show advanced options', 1;
RECONFIGURE;
GO
SP_CONFIGURE 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO
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
EXEC master.[sys].[sp_MSset_oledb_prop] N'Microsoft.ACE.OLEDB.12.0', N'DisallowAdHocAccess', 1
EXEC master.[sys].[sp_MSset_oledb_prop] N'Microsoft.ACE.OLEDB.16.0', N'AllowInProcess', 1

getting error Could not find stored procedure 'sp_configure'. in sql server

I need to change degree of parallelism, but when i run that i am getting error
Could not find stored procedure 'sp_configure'.
Here is my script for that
USE test;
GO
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'max degree of parallelism', 8;
GO
RECONFIGURE WITH OVERRIDE;
GO
It seems you are using Azure SQL Database where sp_configure is not available. Use ALTER DATABASE SCOPED CCONFIGURATION instead to configure MAXDOP.

xp_cmdshell semi-colon separation

I am using xp_cmdshell and i want the output to the text file to be semi-colon separated. I have tested the following:
-- 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; -- 1 for at enable
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
-- Extracting information from the database
EXEC xp_cmdshell 'bcp "SELECT TcpIpAddress FROM [SIT-DVH].[dbo].[Preb_Idera]" queryout "C:\Output\Ip_outputSemi.txt" -T -c -t;'
-- 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 disable the feature.
EXEC sp_configure 'xp_cmdshell', 0; -- 0 for at disable
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
I have seen several places saying that setting -t; should make the output to be semi-colon separated, however the output is still:
xxxx
yyyy
zzzz
I found the solution, since the output is as followed:
xxx
zzz
yyy
i needed to change -t; to -r; since i only have one field per row and [-r row_term], the output is as followed:
xxx;zzz;yyy

Resolve hostnames with t-sql

How can i resolve a hostname in t-sql? a 2000 compatible method is preferred. Although something that works on 2005/2008 would also be helpful.
eg. If i have the hostname stackoverflow.com i want to return 69.59.196.211
Well, I suppose you could use xp_cmdshell to execute nslookup and parse the results. Seems like a really awkward thing for SQL Server to be doing, though.
exec master..xp_cmdshell 'nslookup intel.com'
.. then you'll probably want to stuff that in a temp table and walk through the results.
You could also, if you can get access to SQL Server 2005 or 2008, build a stored procedure or function in .NET and do a simple call to Dns.GetHostAddresses().
SQL Server may block access to procedure 'sys.xp_cmdshell' as part of the security configuration. As a system administrator you can enable the use of 'xp_cmdshell' as follows:
-- Allow advanced options.
EXEC sp_configure 'show advanced options', 1;
GO
-- Update the currently configured value for advanced options.
RECONFIGURE;
GO
-- Then, enable the feature.
EXEC sp_configure 'xp_cmdshell', 1;
GO
-- Update the currently configured value for this feature.
RECONFIGURE;
GO
-- Then you can go ahead and run ...
exec master..xp_cmdshell 'nslookup microsoft.com'
GO