Convert Figma logo to code with AI

microsoft logosql-server-samples

Azure Data SQL Samples - Official Microsoft GitHub Repository containing code samples for SQL Server, Azure SQL, Azure Synapse, and Azure SQL Edge

9,923
8,836
9,923
238

Top Related Projects

The Microsoft JDBC Driver for SQL Server is a Type 4 JDBC driver that provides database connectivity with SQL Server through the standard JDBC application program interfaces (APIs).

31,882

Automatic SQL injection and database takeover tool

Quick Overview

The Microsoft SQL Server Samples repository on GitHub provides a collection of sample code and scripts for working with Microsoft SQL Server. The samples cover a wide range of topics, including database administration, data manipulation, and application development.

Pros

  • Comprehensive Coverage: The repository contains a diverse set of samples, covering various aspects of SQL Server development and administration.
  • Actively Maintained: The repository is actively maintained by the Microsoft SQL Server team, ensuring the samples remain up-to-date and relevant.
  • Learning Resource: The samples can serve as a valuable learning resource for developers and administrators who are new to SQL Server or looking to expand their knowledge.
  • Community Contributions: The repository encourages community contributions, allowing users to share their own SQL Server-related samples and solutions.

Cons

  • Lack of Consistency: The samples may vary in terms of coding style, documentation, and overall quality, as they are contributed by different authors.
  • Potential Outdated Content: Some of the samples may not be updated regularly, and may not reflect the latest features or best practices of SQL Server.
  • Limited Scope: While the repository covers a wide range of topics, it may not provide comprehensive solutions for all SQL Server-related tasks and scenarios.
  • Requires SQL Server Environment: To fully utilize the samples, users need to have a SQL Server environment set up, which may not be accessible to all developers.

Code Examples

Here are a few code examples from the Microsoft SQL Server Samples repository:

  1. Creating a Database and Table:
CREATE DATABASE MyDatabase;
GO

USE MyDatabase;
GO

CREATE TABLE MyTable (
    Id INT PRIMARY KEY,
    Name VARCHAR(50),
    Age INT
);

This code creates a new database named "MyDatabase" and a table named "MyTable" with three columns: "Id", "Name", and "Age".

  1. Inserting Data into a Table:
INSERT INTO MyTable (Id, Name, Age)
VALUES (1, 'John Doe', 30),
       (2, 'Jane Smith', 25),
       (3, 'Bob Johnson', 40);

This code inserts three rows of data into the "MyTable" table.

  1. Querying Data from a Table:
SELECT * FROM MyTable
WHERE Age > 25
ORDER BY Name ASC;

This code selects all rows from the "MyTable" table where the "Age" column is greater than 25, and orders the results by the "Name" column in ascending order.

Getting Started

To get started with the Microsoft SQL Server Samples repository, follow these steps:

  1. Clone the repository to your local machine:
git clone https://github.com/microsoft/sql-server-samples.git
  1. Navigate to the cloned repository:
cd sql-server-samples
  1. Explore the various sample directories, such as "databases", "features", and "tools", to find the samples that are relevant to your needs.

  2. Review the README.md file in each sample directory for instructions on how to set up and run the samples.

  3. Customize the samples as needed and experiment with the provided code to learn more about SQL Server development and administration.

  4. Consider contributing your own SQL Server-related samples to the repository by following the contribution guidelines.

Competitor Comparisons

The Microsoft JDBC Driver for SQL Server is a Type 4 JDBC driver that provides database connectivity with SQL Server through the standard JDBC application program interfaces (APIs).

Pros of mssql-jdbc

  • Focused specifically on JDBC driver implementation for SQL Server
  • More frequent updates and active maintenance
  • Smaller, more manageable codebase for developers working on JDBC connectivity

Cons of mssql-jdbc

  • Limited scope compared to sql-server-samples' broader range of examples
  • Fewer resources for learning SQL Server features beyond JDBC connectivity
  • Less diverse community contributions due to its specialized nature

Code Comparison

mssql-jdbc (Connection example):

String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks;user=MyUserName;password=*****;";
try (Connection connection = DriverManager.getConnection(connectionUrl)) {
    // Use the connection here
}

sql-server-samples (T-SQL query example):

SELECT TOP 10 p.Name AS ProductName, 
    SUM(sd.LineTotal) AS TotalRevenue
FROM SalesLT.Product p
JOIN SalesLT.SalesOrderDetail sd ON p.ProductID = sd.ProductID
GROUP BY p.Name
ORDER BY TotalRevenue DESC;

The mssql-jdbc repository focuses on Java database connectivity, while sql-server-samples provides a wider range of SQL Server examples and use cases across multiple languages and scenarios.

31,882

Automatic SQL injection and database takeover tool

Pros of sqlmap

  • Specialized tool for SQL injection detection and exploitation
  • Active development with frequent updates and community contributions
  • Extensive database support and advanced features for penetration testing

Cons of sqlmap

  • Narrower focus on security testing, not general SQL Server development
  • Potential for misuse if not used responsibly or ethically
  • Steeper learning curve for non-security professionals

Code Comparison

sql-server-samples (T-SQL):

CREATE PROCEDURE dbo.GetCustomerOrders
    @CustomerID INT
AS
BEGIN
    SELECT * FROM Orders WHERE CustomerID = @CustomerID
END

sqlmap (Python):

sqlmap -u "http://example.com/vuln.php?id=1" --dbs
sqlmap -u "http://example.com/vuln.php?id=1" -D database_name --tables
sqlmap -u "http://example.com/vuln.php?id=1" -D database_name -T table_name --dump

Summary

sql-server-samples provides comprehensive examples and best practices for SQL Server development, while sqlmap focuses on security testing and exploitation of SQL injection vulnerabilities. The former is more suitable for general database development and learning, while the latter is a specialized tool for security professionals and penetration testers.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Azure Data SQL Samples Repository

This GitHub repository contains code samples that demonstrate how to use Microsoft's Azure Data products including SQL Server, Azure SQL Database, Azure Synapse, and Azure SQL Edge. Each sample includes a README file that explains how to run and use the sample.

Please note that specific features, such as In-Memory OLTP, are edition-specific for SQL Server. These features will only be available if the edition that supports them is used to run the sample.

Releases in this repository

Releases provide convenient downloads of sample databases and applications, eliminating the need to build them from source code. This SQL Server samples repository offers the following notable releases:

To see the complete list of resources in this repository, navigate to Releases

Working in GitHub

To contribute on GitHub, follow these steps:

  • Visit https://github.com/microsoft/sql-server-samples and fork the repository.
  • Work in your forked repository.
  • When you're ready to make changes or publish your sample for the first time, submit a pull request into the 'master' branch of 'sql-server-samples'.
  • One of the approvers will review your request and either accept or reject the pull request.

Each sample should be in its own folder with a README.md file that follows the template. Generated files (e.g., .exe or .bacpac) and user configuration settings (e.g., .user) should not be committed to GitHub.

Cloning only a subset of the repo (with sparse checkout)

You can follow the steps below to clone individual files from the sql-server-samples git repo. Note: The following script clones only the files under the features and demos folders.

git clone -n https://github.com/Microsoft/sql-server-samples
cd sql-server-samples
git config core.sparsecheckout true
echo samples/features/*| out-file -append -encoding ascii .git/info/sparse-checkout
echo samples/demos/*| out-file -append -encoding ascii .git/info/sparse-checkout
git checkout

For more information about sparse checkout please visit this stackoverflow thread.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

License

These samples and templates are all licensed under the MIT license. See the license.txt file in the root.

Questions

Email questions to: sqlserversamples@microsoft.com.