What is Connection String in SQL SERVER PART 3 With Example Code

In this configuration, you have one "ConnectionString" key with the connection string for connecting to the SQL Server instance running on "DESKTOP\DB".If you want to specify multiple connection strings for different environments or scenarios, you can define them using unique keys. For example



{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "Data": {
    "LocalConnectionString": "Data Source=DESKTOP\\DB;Initial Catalog=DB;Integrated Security=True;",
    "RemoteConnectionString": "Data Source=123.123.123.123;Initial Catalog=DB;Integrated Security=False;User ID=sa;Password=123"
  }
}

 To show all settings in SQL Server, you can query various system catalog views and dynamic management views (DMVs) to gather comprehensive information about the server configuration. Here's a script that provides an overview of different settings and configurations:

-- Show all settings in SQL Server

 

-- Database engine configuration settings
SELECT * FROM sys.configurations;
 
-- Show server properties
EXEC sp_configure;
 
-- Show server-level settings
SELECT * FROM sys.dm_server_services;
 
-- Show advanced server properties
EXEC xp_instance_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\Setup', 'SQLDataRoot';
EXEC xp_instance_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\Setup', 'SQLPath';
 
-- Show server version information
SELECT @@VERSION;