### Start SQL Server Setup to Generate Configuration File Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/install-sql-server-using-a-configuration-file.md Use this command to start the SQL Server installation process and generate a configuration file. This is particularly useful for SQL Server Express Edition. ```command-line SETUP.exe /UIMODE=Normal /ACTION=INSTALL ``` -------------------------------- ### SQL Server Command-Line Installation Parameters Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/install-sql-server-from-the-command-prompt.md Examples of common SQL Server installation parameters and their usage. ```bash setup.exe /INDICATEPROGRESS ``` ```bash setup.exe /SQLSVCINSTANTFILEINIT=True ``` ```bash setup.exe /TCPENABLED=1 ``` ```bash setup.exe /PID="PID" /SQLSVCSTARTUPTYPE="Automatic" ``` ```bash setup.exe /SQLSYSADMINACCOUNTS="Contoso\John" "Contoso\Mary" ``` ```bash setup.exe /INSTANCEDIR=C:\Path ``` ```bash setup.exe /INSTANCEDIR="C:\Path" ``` ```bash setup.exe /FEATURES=AS,RS,IS ``` -------------------------------- ### Run the installation script Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/linux/install-upgrade/unattended-install-redhat.md Execute the bash script to start the unattended installation of SQL Server. ```bash ./install_sql.sh ``` -------------------------------- ### Install openSUSE Linux prerequisites Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/python/mssql-python/python-sql-driver-mssql-python-connect-jupyter-notebook.md Install necessary libraries for openSUSE Linux. This is a one-time OS-specific setup. ```console zypper install -y libltdl7 ``` -------------------------------- ### Install Debian/Ubuntu Linux prerequisites Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/python/mssql-python/python-sql-driver-mssql-python-connect-jupyter-notebook.md Install necessary libraries for Debian/Ubuntu Linux. This is a one-time OS-specific setup. ```console apt-get install -y libltdl7 libkrb5-3 libgssapi-krb5-2 ``` -------------------------------- ### Install SUSE Linux prerequisites Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/python/mssql-python/python-sql-driver-mssql-python-connect-jupyter-notebook.md Install necessary libraries for SUSE Linux. This is a one-time OS-specific setup. ```console zypper install -y libltdl7 libkrb5-3 libgssapi-krb5-2 ``` -------------------------------- ### Main Function Setup Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/oledb/ole-db-how-to/filestream/retrieve-data-from-a-filestream-column-using-isequentialstream-ole-db.md Initializes COM, opens a connection to a SQL Server, and retrieves the ICommandText interface. This is the entry point for the example. Requires CoInitialize, OpenSessionSS, and ICommandText. ```cpp void wmain(int argc, wchar_t* argv[]) { #define PARAM_COUNT 2 HRESULT hr; IDBCreateCommand * pIDBCreateCommand = NULL; ICommandText * pICommandText = NULL; ICommandPrepare * pICommandPrepare = NULL; IAccessor * pIAccessor = NULL; IRowset * pIRowset = NULL; ICommandProperties * pICommandProperties = NULL; HACCESSOR hAccessor; DBBINDING dbBind[PARAM_COUNT]; DBROWCOUNT rows; DBPROPSET rgCmdPropSet[1]; DBPROP rgCmdProperties[1]; if ( argc < 2 ) { wprintf( L"Usage: %s: \n", argv[0] ); return; } CoInitialize(NULL); // Open connection to SS database. hr = OpenSessionSS( &pIDBCreateCommand, argv[1] ); CHECK_HR_ERR(hr,MainCleanup); // Get ICommandText. hr = pIDBCreateCommand->CreateCommand( NULL, IID_ICommandText, (IUnknown**)&pICommandText ); ``` -------------------------------- ### Copy data using SqlBulkCopy and SqlDataReader Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/ado-net/sql/single-bulk-copy-operations.md This C# example demonstrates loading data from a SqlDataReader into a destination table using the SqlBulkCopy class. Ensure the work tables are set up as per the 'Bulk copy example setup' guide before running. ```csharp using System; using Microsoft.Data.SqlClient; using System.Data; public class SqlBulkCopy_WriteToServer { public static void Main(string[] args) { // Connection string to the AdventureWorks database. // Make sure to replace the server name and database name with your own values. string connectionString = "Server=your_server_name;Database=AdventureWorks;Integrated Security=SSPI;"; // Source and destination table names. string sourceTableName = "Production.Product"; string destinationTableName = "dbo.T_Product"; // Create a SqlConnection to the source database. using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); // Create a SqlCommand to select data from the source table. string selectCommand = "SELECT ProductID, Name, ProductNumber, Color, " + "ListPrice, SellStartDate FROM Production.Product"; SqlCommand command = new SqlCommand(selectCommand, connection); // Create a SqlDataReader to read data from the source table. using (SqlDataReader reader = command.ExecuteReader()) { // Create a SqlBulkCopy object. using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection)) { // Set the destination table name. bulkCopy.DestinationTableName = destinationTableName; // Set the batch size. bulkCopy.BatchSize = 5000; // Set the column mappings. bulkCopy.ColumnMappings.Add("ProductID", "ProductID"); bulkCopy.ColumnMappings.Add("Name", "Name"); bulkCopy.ColumnMappings.Add("ProductNumber", "ProductNumber"); bulkCopy.ColumnMappings.Add("Color", "Color"); bulkCopy.ColumnMappings.Add("ListPrice", "ListPrice"); bulkCopy.ColumnMappings.Add("SellStartDate", "SellStartDate"); // Write data to the destination table. bulkCopy.WriteToServer(reader); } } } Console.WriteLine("Data copied successfully."); } } ``` -------------------------------- ### Complete Example: User Context and Permissions Tutorial Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/relational-databases/tutorial-ownership-chains-and-context-switching.md This comprehensive script sets up users, logins, schemas, and stored procedures to demonstrate ownership chains and context switching in SQL Server. ```sql /* Script: UserContextTutorial.sql Author: Microsoft Last Updated: Books Online Conditions: Execute as DBO or sysadmin in the AdventureWorks database Section 1: Configure the Environment */ USE AdventureWorks2022; GO SELECT CURRENT_USER AS 'Current User Name'; GO /* Create server and database users */ CREATE LOGIN TestManagerUser WITH PASSWORD = '340$Uuxwp7Mcxo7Khx'; GO CREATE USER TestManagerUser FOR LOGIN TestManagerUser WITH DEFAULT_SCHEMA = Purchasing; GO CREATE LOGIN TestEmployeeUser WITH PASSWORD = '340$Uuxwp7Mcxo7Khy'; GO CREATE USER TestEmployeeUser FOR LOGIN TestEmployeeUser; GO /* Change owner of the Purchasing Schema to TestManagerUser */ ALTER AUTHORIZATION ON SCHEMA::Purchasing TO TestManagerUser; GO GRANT CREATE PROCEDURE TO TestManagerUser WITH GRANT OPTION; GO /* Section 2: Switch Context and Create Objects */ EXECUTE AS LOGIN = 'TestManagerUser'; GO SELECT CURRENT_USER AS 'Current User Name'; GO /* Note: The user that calls the EXECUTE AS statement must have IMPERSONATE permissions on the target principal */ CREATE PROCEDURE usp_ShowWaitingItems @ProductID int AS BEGIN SELECT a.PurchaseOrderID, a.OrderDate, a.ShipDate , b.ProductID, b.OrderQty, b.ReceivedQty FROM Purchasing.PurchaseOrderHeader AS a INNER JOIN Purchasing.PurchaseOrderDetail AS b ON a.PurchaseOrderID = b.PurchaseOrderID WHERE b.OrderQty > b.ReceivedQty AND @ProductID = b.ProductID ORDER BY b.ProductID ASC END; GO /* Give the employee the ability to run the procedure */ GRANT EXECUTE ON OBJECT::Purchasing.usp_ShowWaitingItems TO TestEmployeeUser; GO /* Notice that the stored procedure is located in the Purchasing schema. This also demonstrates system catalogs */ SELECT a.name AS 'Schema' , b.name AS 'Object Name' , b.type AS 'Object Type' FROM sys.schemas AS a INNER JOIN sys.objects AS b ON a.schema_id = b.schema_id WHERE b.name = 'usp_ShowWaitingItems'; GO /* Go back to being the dbo user */ REVERT; GO /* Section 3: Switch Context and Observe Security */ EXECUTE AS LOGIN = 'TestEmployeeUser'; GO SELECT CURRENT_USER AS 'Current User Name'; GO EXEC Purchasing.usp_ShowWaitingItems 952; GO /* Section 4: Clean Up Example */ REVERT; GO ALTER AUTHORIZATION ON SCHEMA::Purchasing TO dbo; GO DROP PROCEDURE Purchasing.usp_ShowWaitingItems; GO DROP USER TestEmployeeUser; GO DROP USER TestManagerUser; GO DROP LOGIN TestEmployeeUser; GO DROP LOGIN TestManagerUser; GO ``` -------------------------------- ### Get Boundary of LineString with Same Endpoints Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/t-sql/spatial-geometry/stboundary-geometry-data-type.md This example shows how STBoundary() behaves when applied to a LineString geometry instance where the start and end points are identical. In such cases, it returns an empty GeometryCollection. ```T-SQL DECLARE @g geometry; SET @g = geometry::STGeomFromText('LINESTRING(0 0, 2 2, 0 2, -2 2, 0 0)', 0); SELECT @g.STBoundary().ToString(); ``` -------------------------------- ### Display SQL Server Setup Help Information Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/install-sql-server-from-the-command-prompt.md Run this command to view a list of all available parameters and options for the SQL Server Setup executable in the console. ```console C:\SQLMedia\SQLServer2025> setup.exe /help ``` -------------------------------- ### Setup Database, Logins, and Schemas Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/relational-databases/xml/grant-permissions-on-an-xml-schema-collection.md Creates necessary logins, a database, and relational schemas for demonstrating XML schema collection permissions. ```sql CREATE LOGIN TestLogin1 with password='SQLSvrPwd1'; GO CREATE LOGIN TestLogin2 with password='SQLSvrPwd2'; GO CREATE DATABASE SampleDBForSchemaPermissions; GO USE SampleDBForSchemaPermissions; GO -- Create another relational schema in the database. CREATE SCHEMA myOtherDBSchema; GO -- Create users in the database. Note TestLogin2's default schema is -- myOtherDBSchema. CREATE USER TestLogin1; GO CREATE USER TestLogin2 WITH DEFAULT_SCHEMA=myOtherDBSchema; GO -- TestLogin2 will own myOtherDBSchema relational schema. ALTER AUTHORIZATION ON SCHEMA::myOtherDBSchema TO TestLogin2; GO ``` -------------------------------- ### SQL Server Browser Service Start Failure Error Message Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/sql-server/sql-server-2012-release-notes.md This error message indicates a failure during SQL Server Setup when attempting to start the SQL Server Browser service. It may occur if the SQL Server Engine or Analysis Services failed to install. ```text The following error has occurred: Service 'SQLBrowser' start request failed. Click 'Retry' to retry the failed action, or click 'Cancel' to cancel this action and continue setup. ``` ```text The following error has occurred: SQL Server Browser configuration for feature 'SQL_Browser_Redist_SqlBrowser_Cpu32' was cancelled by user after a previous installation failure. The last attempted step: Starting the SQL Server Browser service 'SQLBrowser', and waiting for up to '900' seconds for the process to complete. ``` -------------------------------- ### Get Boundary of LineString with Different Endpoints Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/t-sql/spatial-geometry/stboundary-geometry-data-type.md This example demonstrates how to use STBoundary() to retrieve the boundary of a LineString geometry instance that has different start and end points. The result is a geometry instance representing the boundary. ```T-SQL DECLARE @g geometry; SET @g = geometry::STGeomFromText('LINESTRING(0 0, 2 2, 0 2, 2 0)', 0); SELECT @g.STBoundary().ToString(); ``` -------------------------------- ### Build the Java Sample Project Source: https://github.com/microsoftdocs/sql-docs/blob/live/azure-sql/database/elastic-scale-get-started.md Use Maven to build the sample project from the command line. Ensure you are in the './sample' directory. ```cmd mvn install ``` -------------------------------- ### Guid Function Example Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/relational-databases/policy-based-management/advanced-edit-condition-dialog-box.md Creates a GUID from a string representation. Useful for conditions involving GUIDs. ```Policy-Based Management Guid('12340000-0000-3455-0000-000000000454') ``` -------------------------------- ### Example Startup Parameters for Master Database Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/relational-databases/databases/move-system-databases.md Shows the default startup parameter values for the master data and log files. Use this as a reference when updating paths. ```output -dC:\Program Files\Microsoft SQL Server\MSSQL.MSSQLSERVER\MSSQL\DATA\master.mdf -lC:\Program Files\Microsoft SQL Server\MSSQL.MSSQLSERVER\MSSQL\DATA\mastlog.ldf ``` -------------------------------- ### Example: Get All Members from a Specific Dimension Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/mdx/root-mdx.md This example shows how to use Root with a dimension name to get 'All' members from the Date dimension and intersect with a specific measure. ```mdx SELECT Root([Date]) ON 0 FROM [Adventure Works] WHERE [Measures].[Order Count] ``` -------------------------------- ### Create and Configure Sample Databases Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/availability-groups/windows/create-an-availability-group-transact-sql.md Creates two sample databases, MyDb1 and MyDb2, and sets their recovery model to FULL. Execute this on the server instance that will host the primary replica. ```sql -- Create sample databases: CREATE DATABASE MyDb1; GO ALTER DATABASE MyDb1 SET RECOVERY FULL; GO CREATE DATABASE MyDb2; GO ALTER DATABASE MyDb2 SET RECOVERY FULL; GO ``` -------------------------------- ### Install and Start Samba on RHEL/SLES Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/linux/replication/snapshot-shares.md Installs the Samba package and starts the SMB service on Red Hat Enterprise Linux (RHEL) or SUSE Linux Enterprise Server (SLES). ```bash sudo yum install samba sudo service smb start sudo service smb status ``` -------------------------------- ### SQL Server Setup Wizard Rule for Slipstream Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/install-sql-server-using-slipstream.md This rule appears in the setup wizard when SQL Server is being installed using a slipstreamed update. It helps confirm the installation method. ```output Update Setup Media Language Rule ``` -------------------------------- ### Initialize Project with uv Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/python/mssql-python/python-sql-driver-mssql-python-rapid-prototyping-quickstart.md Create a new project directory and navigate into it using the 'uv' tool. This sets up the project structure for rapid prototyping. ```console uv init rapid-prototyping-qs cd rapid-prototyping-qs ``` -------------------------------- ### Start Docker Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/linux/install-upgrade/quickstart-install-docker.md Starts the Docker daemon. This command is necessary after installation or system reboot. ```bash sudo systemctl start docker ``` -------------------------------- ### Create and Populate Sample Table Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/relational-databases/import-export/use-native-format-to-import-or-export-data-sql-server.md Creates a sample database and table, then populates it with initial data for import/export examples. ```sql CREATE DATABASE TestDatabase; GO USE TestDatabase; CREATE TABLE dbo.myNative ( PersonID smallint NOT NULL, FirstName varchar(25) NOT NULL, LastName varchar(30) NOT NULL, BirthDate date, AnnualSalary money ); -- Populate table INSERT TestDatabase.dbo.myNative VALUES (1, 'Anthony', 'Grosse', '1980-02-23', 65000.00), (2, 'Alica', 'Fatnowna', '1963-11-14', 45000.00), (3, 'Stella', 'Rossenhain', '1992-03-02', 120000.00); -- Review Data SELECT * FROM TestDatabase.dbo.myNative; ``` -------------------------------- ### Install macOS prerequisites Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/python/mssql-python/python-sql-driver-mssql-python-connect-jupyter-notebook.md Install OpenSSL for macOS using Homebrew. This is a one-time OS-specific setup. ```console brew install openssl ``` -------------------------------- ### Get Help for setup-ad-keytab Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/linux/configure/mssql-conf.md Use this command to view the help information for the setup-ad-keytab option, which is used for creating keytabs for Active Directory authentication. ```bash sudo /opt/mssql/bin/mssql-conf setup-ad-keytab --help ``` -------------------------------- ### C++ Example: Initialize COM, Create Instance, Set Properties, and Initialize Connection Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/oledb/ole-db-how-to/results/execute-stored-procedure-with-rpc-and-process-output.md This C++ code demonstrates initializing the COM library, creating an OLE DB instance, setting connection properties like server name and database, and establishing a connection. ```cpp void InitializeAndEstablishConnection() { // Initialize the COM library. CoInitialize(NULL); // Obtain access to the OLE DB Driver for SQL Server. hr = CoCreateInstance( CLSID_MSOLEDBSQL, NULL, CLSCTX_INPROC_SERVER,IID_IDBInitialize, (void **) &pIDBInitialize); if (FAILED(hr)) cout << "Failed in CoCreateInstance().\n"; // Initialize the property values needed to establish the connection. for (i = 0 ; i < nInitProps ; i++ ) VariantInit(&InitProperties[i].vValue); //Specify server name. InitProperties[0].dwPropertyID = DBPROP_INIT_DATASOURCE; InitProperties[0].vValue.vt = VT_BSTR; // Replace "MySqlServer" with proper value. InitProperties[0].vValue.bstrVal = SysAllocString(L"(local)"); InitProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED; InitProperties[0].colid = DB_NULLID; // Specify database name. InitProperties[1].dwPropertyID = DBPROP_INIT_CATALOG; InitProperties[1].vValue.vt = VT_BSTR; InitProperties[1].vValue.bstrVal = SysAllocString(L"AdventureWorks"); InitProperties[1].dwOptions = DBPROPOPTIONS_REQUIRED; InitProperties[1].colid = DB_NULLID; InitProperties[2].dwPropertyID = DBPROP_AUTH_INTEGRATED; InitProperties[2].vValue.vt = VT_BSTR; InitProperties[2].vValue.bstrVal = SysAllocString(L"SSPI"); InitProperties[2].dwOptions = DBPROPOPTIONS_REQUIRED; InitProperties[2].colid = DB_NULLID; // Properties are set, construct the DBPROPSET structure (rgInitPropSet) used to pass // an array of // DBPROP structures (InitProperties) to the SetProperties method. rgInitPropSet[0].guidPropertySet = DBPROPSET_DBINIT; rgInitPropSet[0].cProperties = 4; rgInitPropSet[0].rgProperties = InitProperties; // Set initialization properties. hr = pIDBInitialize->QueryInterface( IID_IDBProperties, (void **)&pIDBProperties); if ( FAILED(hr)) cout << "Failed to obtain IDBProperties interface.\n"; hr = pIDBProperties->SetProperties( nPropSet, rgInitPropSet); if (FAILED(hr)) cout << "Failed to set initialization properties.\n"; pIDBProperties->Release(); // Now establish a connection to the data source. if ( FAILED(pIDBInitialize->Initialize()) ) cout << "Problem in initializing.\n"; } ``` -------------------------------- ### SQL Server Configuration File Example (SQL Server 2022 and later) Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/install-sql-server-using-a-configuration-file.md This is an example of a ConfigurationFile.ini for SQL Server 2022 and later versions. It specifies the installation action and the features to be installed, such as the Database Engine. ```ini ; Microsoft SQL Server Configuration file [OPTIONS] ; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. ; This is a required parameter. ACTION="Install" ; Specifies features to install, uninstall, or upgrade. ; The list of top-level features include SQL, AS, and IS. ; The SQL feature will install the database engine, replication, and full-text. FEATURES=SQL ``` -------------------------------- ### Example Output of kubectl get pods Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/linux/business-continuity/containers/tutorial-kubernetes-dxoperator.md This is an example output of the 'kubectl get pods' command, showing the status of the SQL Server pods within the cluster. It confirms that the pods are running and provides their age. ```output NAME READY STATUS RESTARTS AGE contoso-sql-0 2/2 Running 0 74m contoso-sql-1 2/2 Running 0 74m contoso-sql-2 2/2 Running 0 74m ``` -------------------------------- ### Complete Example: Manage Role Membership and Test Permissions Source: https://github.com/microsoftdocs/sql-docs/blob/live/azure-sql/database/security-server-roles.md A comprehensive example demonstrating adding a login to a server role, verifying membership via metadata, creating a user in a database, and testing server and database-level permissions. ```sql ALTER SERVER ROLE ##MS_ServerStateReader## ADD MEMBER Jiao; -- check membership in metadata: SELECT IS_SRVROLEMEMBER('##MS_ServerStateReader##', 'Jiao'); --> 1 = Yes SELECT sql_logins.principal_id AS MemberPrincipalID, sql_logins.name AS MemberPrincipalName, roles.principal_id AS RolePrincipalID, roles.name AS RolePrincipalName FROM sys.server_role_members AS server_role_members INNER JOIN sys.server_principals AS roles ON server_role_members.role_principal_id = roles.principal_id INNER JOIN sys.sql_logins AS sql_logins ON server_role_members.member_principal_id = sql_logins.principal_id; GO ``` ```sql -- Create a database-User for 'Jiao' CREATE USER Jiao FROM LOGIN Jiao; GO ``` ```sql -- retrieve server-level permissions of currently logged on User SELECT * FROM sys.fn_my_permissions(NULL, 'Server'); -- check server-role membership for `##MS_ServerStateReader##` of currently logged on User SELECT USER_NAME(), IS_SRVROLEMEMBER('##MS_ServerStateReader##'); --> 1 = Yes -- Does the currently logged in User have the `VIEW DATABASE STATE`-permission? SELECT HAS_PERMS_BY_NAME(NULL, 'DATABASE', 'VIEW DATABASE STATE'); --> 1 = Yes -- retrieve database-level permissions of currently logged on User SELECT * FROM sys.fn_my_permissions(NULL, 'DATABASE'); GO -- example query: SELECT * FROM sys.dm_exec_query_stats; --> will return data since this user has the necessary permission ``` -------------------------------- ### SQL Server Configuration File Example (SQL Server 2016-2019) Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/install-sql-server-using-a-configuration-file.md This is an example of a ConfigurationFile.ini for SQL Server versions 2016 through 2019. It specifies the installation action and the features to be installed, such as the Database Engine and Management Tools. ```ini ; Microsoft SQL Server Configuration file [OPTIONS] ; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. ; This is a required parameter. ACTION="Install" ; Specifies features to install, uninstall, or upgrade. ; The list of top-level features include SQL, AS, RS, IS, and Tools. ; The SQL feature will install the database engine, replication, and full-text. ; The Tools feature will install Management Tools, Books online, ; SQL Server Data Tools, and other shared components. FEATURES=SQL,Tools ``` -------------------------------- ### Full Example: Create Account, Profile, and Grant Public Access Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/relational-databases/database-mail/create-a-database-mail-profile.md This comprehensive example demonstrates creating a Database Mail account, a private profile, adding the account to the profile, and then granting public access to the profile. ```sql -- Create a Database Mail account EXECUTE msdb.dbo.sysmail_add_account_sp @account_name = 'AdventureWorks Public Account', @description = 'Mail account for use by all database users.', @email_address = 'db_users@Adventure-Works.com', @replyto_address = 'danw@Adventure-Works.com', @display_name = 'AdventureWorks Automated Mailer', @mailserver_name = 'smtp.Adventure-Works.com' ; -- Create a Database Mail profile EXECUTE msdb.dbo.sysmail_add_profile_sp @profile_name = 'AdventureWorks Public Profile', @description = 'Profile used for administrative mail.' ; -- Add the account to the profile EXECUTE msdb.dbo.sysmail_add_profileaccount_sp @profile_name = 'AdventureWorks Public Profile', @account_name = 'AdventureWorks Public Account', @sequence_number =1 ; -- Grant access to the profile to all users in the msdb database EXECUTE msdb.dbo.sysmail_add_principalprofile_sp @profile_name = 'AdventureWorks Public Profile', @principal_name = 'public', @is_default = 1 ; ``` -------------------------------- ### Setup and Initial Data Insertion Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/t-sql/xml/replace-value-of-xml-dml.md This snippet sets up a table with a typed XML column and inserts sample data from the Production.ProductModel table for demonstration purposes. ```sql USE AdventureWorks2022; GO DROP TABLE T; GO CREATE TABLE T ( ProductModelID INT PRIMARY KEY, Instructions XML(Production.ManuInstructionsSchemaCollection) ); GO INSERT T SELECT ProductModelID, Instructions FROM Production.ProductModel WHERE ProductModelID = 7; GO ``` -------------------------------- ### Example Deployment Output Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/ssdt/walkthrough-extend-database-project-deployment-to-analyze-the-deployment-plan.md This output shows the paths to the generated deployment summary and details XML files, as well as the deployment script. ```output ------ Deploy started: Project: Database1, Configuration: Debug Any CPU ------ Finished verifying cached model in 00:00:00 Deployment reports -> C:\Users\UserName\Documents\Visual Studio 2012\Projects\MyDatabaseProject\MyDatabaseProject\sql\debug\MyTargetDatabase.summary.xml C:\Users\UserName\Documents\Visual Studio 2012\Projects\MyDatabaseProject\MyDatabaseProject\sql\debug\MyTargetDatabase.details.xml Deployment script generated to: C:\Users\UserName\Documents\Visual Studio 2012\Projects\MyDatabaseProject\MyDatabaseProject\sql\debug\MyDatabaseProject.sql ``` -------------------------------- ### Launch Setup with Passwords and Custom Configuration File Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/install-sql-server-on-server-core.md Launches SQL Server setup, specifying SQL Server and Analysis Services passwords directly on the command line along with a custom configuration file. ```console setup.exe /QS /SQLSVCPASSWORD="************" /ASSVCPASSWORD="************" /ConfigurationFile=MyConfigurationFile.INI ``` -------------------------------- ### Run SQL Server Discovery Report from Command Line Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/validate-a-sql-server-installation.md Execute Setup.exe with the RunDiscovery action to generate the SQL Server features discovery report from the command line. Use the /q flag for a quiet installation without UI. ```bash Setup.exe /Action=RunDiscovery ``` ```bash Setup.exe /Action=RunDiscovery /q ``` -------------------------------- ### Install RHEL Linux prerequisites Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/python/mssql-python/python-sql-driver-mssql-python-connect-jupyter-notebook.md Install necessary libraries for RHEL Linux. This is a one-time OS-specific setup. ```console dnf install -y libtool-ltdl krb5-libs ``` -------------------------------- ### Launch Setup with Custom Configuration File Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/install-sql-server-on-server-core.md Launches SQL Server setup using a specified custom INI configuration file. ```console setup.exe /QS /ConfigurationFile=MyConfigurationFile.INI ``` -------------------------------- ### Install Alpine Linux prerequisites Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/python/mssql-python/python-sql-driver-mssql-python-connect-jupyter-notebook.md Install necessary libraries for Alpine Linux. This is a one-time OS-specific setup. ```console apk add libtool krb5-libs krb5-dev ``` -------------------------------- ### Table Setup for Bulk Copy Examples Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/jdbc/using-bulk-copy-with-the-jdbc-driver.md Creates the necessary tables in the AdventureWorks2022 database for demonstrating bulk copy operations. Includes setup for matching and different column scenarios, as well as order header and detail tables. ```sql USE AdventureWorks2022; GO IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[BulkCopyDemoMatchingColumns]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE [dbo].[BulkCopyDemoMatchingColumns] CREATE TABLE [dbo].[BulkCopyDemoMatchingColumns]([ProductID] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](50) NOT NULL, [ProductNumber] [nvarchar](25) NOT NULL, CONSTRAINT [PK_ProductID] PRIMARY KEY CLUSTERED ( [ProductID] ASC ) ON [PRIMARY]) ON [PRIMARY] IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[BulkCopyDemoDifferentColumns]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE [dbo].[BulkCopyDemoDifferentColumns] CREATE TABLE [dbo].[BulkCopyDemoDifferentColumns]([ProdID] [int] IDENTITY(1,1) NOT NULL, [ProdNum] [nvarchar](25) NOT NULL, [ProdName] [nvarchar](50) NOT NULL, CONSTRAINT [PK_ProdID] PRIMARY KEY CLUSTERED ( [ProdID] ASC ) ON [PRIMARY]) ON [PRIMARY] IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[BulkCopyDemoOrderHeader]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE [dbo].[BulkCopyDemoOrderHeader] CREATE TABLE [dbo].[BulkCopyDemoOrderHeader]([SalesOrderID] [int] IDENTITY(1,1) NOT NULL, [OrderDate] [datetime] NOT NULL, [AccountNumber] [nvarchar](15) NULL, CONSTRAINT [PK_SalesOrderID] PRIMARY KEY CLUSTERED ( [SalesOrderID] ASC ) ON [PRIMARY]) ON [PRIMARY] IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[BulkCopyDemoOrderDetail]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE [dbo].[BulkCopyDemoOrderDetail] CREATE TABLE [dbo].[BulkCopyDemoOrderDetail]([SalesOrderID] [int] NOT NULL, [SalesOrderDetailID] [int] NOT NULL, [OrderQty] [smallint] NOT NULL, [ProductID] [int] NOT NULL, [UnitPrice] [money] NOT NULL, CONSTRAINT [PK_LineNumber] PRIMARY KEY CLUSTERED ( [SalesOrderID] ASC, [SalesOrderDetailID] ASC ) ON [PRIMARY]) ON [PRIMARY] ``` -------------------------------- ### Initialize Project with uv Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/connect/python/mssql-python/python-sql-driver-mssql-python-bulk-copy-quickstart.md Initializes a new Python project named 'mssql-python-bcp-qs' and navigates into the project directory. ```console uv init mssql-python-bcp-qs cd mssql-python-bcp-qs ``` -------------------------------- ### Get Top 5 Subcategories by Gross Profit using Subset Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/mdx/subset-mdx.md This example demonstrates how to use the Subset function in conjunction with the Order function to retrieve the top 5 product subcategories based on reseller gross profit. The starting position is 0 (the first element) and the count is 5. ```mdx SELECT Subset (Order ([Product].[Product Categories].[SubCategory].members ,[Measures].[Reseller Gross Profit] ,BDESC ) ,0 ,5 ) ON 0 FROM [Adventure Works] ``` -------------------------------- ### Prepare a new SQL Server instance image Source: https://github.com/microsoftdocs/sql-docs/blob/live/docs/database-engine/install-windows/install-sql-server-from-the-command-prompt.md Use this command to prepare a new, stand-alone instance with specified components like SQL Server, Replication, Full-Text Search, and Reporting Services. ```console setup.exe /q /ACTION=PrepareImage /FEATURES=SQL,RS /InstanceID = /IACCEPTSQLSERVERLICENSETERMS ```