//------------------------------------------------------------------------------
// <copyright file="CSSqlStoredProcedure.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;

public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void StoredProcedure1()
    {
        using (SqlConnection connection = new SqlConnection("context connection=true"))
        {
            // Nicht die Verbindung, sondern das SqlConnection-Objekt wird geöffnet!
            connection.Open();

            using (SqlCommand command = connection.CreateCommand())
            {
                command.CommandType = CommandType.Text;
                command.CommandText = "select * from Customers;";

                SqlContext.Pipe.ExecuteAndSend(command);
            }
        } // Close() wird indirekt durch Verlassen des using-Blocks aufgerufen
    }
};