영어로 읽기

다음을 통해 공유


SqlContext 클래스

정의

SqlPipe, SqlTriggerContextWindowsIdentity 개체에 대한 액세스를 제공하는 호출자 컨텍스트의 추상화를 나타냅니다. 이 클래스는 상속될 수 없습니다.

C#
public sealed class SqlContext
상속
SqlContext

예제

다음 예제에서는 새 SqlDataRecordSqlMetaData입니다. 예제는 다음 결과 사용 하 여 집합의 시작을 표시 합니다 SendResultsStart 메서드를 사용 하 여 클라이언트에 다시 예제 데이터를 사용 하 여 레코드를 보냅니다 합니다 SendResultsRow 메서드를 사용 하 여 결과의 끝 설정 표시를 SendResultsEnd 메서드.

C#
[Microsoft.SqlServer.Server.SqlProcedure]
public static void StoredProcReturnResultSet()
{
    // Create the record and specify the metadata for the columns.
    SqlDataRecord record = new SqlDataRecord(
        new SqlMetaData("col1", SqlDbType.NVarChar, 100),
        new SqlMetaData("col2", SqlDbType.Int));

    // Mark the begining of the result-set.
    SqlContext.Pipe.SendResultsStart(record);

    // Send 10 rows back to the client.
    for (int i = 0; i < 10; i++)
    {
        // Set values for each column in the row.
        record.SetString(0, "row " + i.ToString());
        record.SetInt32(1, i);

        // Send the row back to the client.
        SqlContext.Pipe.SendResultsRow(record);
    }

    // Mark the end of the result-set.
    SqlContext.Pipe.SendResultsEnd();
}

설명

SqlContext 개체 (에 대 한 트리거 내에서 실행 되는 코드)는 트리거 컨텍스트 및 파이프 개체 (사용 가능한 경우와 같이 저장된 프로시저에서)를 가져오는 데 사용할 수 있습니다. 가져올 때도 사용 수를 WindowsIdentity 통합 인증을 사용 하 여 서버와 클라이언트를 인증 하는 경우 호출 클라이언트의 Microsoft Windows id를 나타내는 개체입니다.

속성

IsAvailable

호출 코드가 SQL Server 내에서 실행되고 있는지와 컨텍스트 연결에 액세스할 수 있는지 여부를 지정합니다.

Pipe

호출자가 결과 집합, 메시지 및 명령 실행 결과를 클라이언트에게 다시 보낼 수 있도록 하는 파이프 개체를 가져옵니다.

TriggerContext

트리거를 발생시킨 작업에 대한 정보와 업데이트된 열의 맵을 호출자에 제공하는 데 사용되는 트리거 컨텍스트를 가져옵니다.

WindowsIdentity

호출자의 Microsoft Windows ID입니다.

적용 대상

제품 버전
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1