Home Microsoft SQL Server DigiMailing iRN Contact


  No additional text.

create procedure sys.sp_MSsetcontext_internalcaller @onoff bit -- 1 to turn on
    declare @cur_context varbinary(128)
    declare @cur_context_second_byte binary(1)
    declare @bitmask tinyint

    -- First Byte
    -- bit to set: snapshot=1, logreader=2, distrib=4, merge=8,
    -- replication_agent=16, merge_identityrange_alterconstraint=32
    -- bypasswholeddleventbit=64, bypassreplicateddleventbit=128
    -- Second Byte
    -- bit to set: internalcaller = 1

    if @onoff=1
        set @bitmask=1
        set @bitmask=255-1

    -- get the current context_info. remember we only want to modify a bit without changing the rest of the info
    select @cur_context = isnull(context_info(),0x00)

    -- get the second byte out.
    select @cur_context_second_byte = substring(@cur_context, 2, 1)
    -- set the appropriate bit in this one byte (leaving other bits unchanged).
    if @onoff=1
        select @cur_context_second_byte = (convert(tinyint,@cur_context_second_byte) | @bitmask)
        select @cur_context_second_byte = (convert(tinyint,@cur_context_second_byte) & @bitmask)

    -- replace the first byte of the 128 byte binary variable, so that now it has the appropriate bit set.
    select @cur_context = convert(varbinary(128),stuff (convert(binary(128), @cur_context), 2, 1, @cur_context_second_byte))
    -- set the context_info again with the new binary(128) value.
    set context_info @cur_context

    if @@error <> 0
        return 1

    return 0

Last revision 2008RTM
See also

  sp_MSmerge_altertable (Procedure)
sp_repladdcolumn (Procedure)
sp_repldropcolumn (Procedure)


  Query a named instance
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
Zoekmachine optimalisatie
SQL Servers hidden objects
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
sIFR; de combinatie tussen HTML en Flash