Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSsetbit

  No additional text.


Syntax
create procedure sys.sp_MSsetbit
    @bm varbinary(128) output,
    @coltoadd smallint,
    @toset    int = 1
AS
    declare @bytenum smallint
    declare @bit smallint
    declare @mask tinyint
    declare @newbyte tinyint
    declare @oldbyte tinyint

    SELECT @bytenum = 1 + FLOOR((@coltoadd-1)/8)

    IF @bytenum > 128 return 0

    SELECT @bit = (@coltoadd-1) % 8

    SET @mask = POWER(2, @bit)
    if @toset = 0
        SET @mask = (~@mask % 256)

    if @bm is null
        set @bm = 0x0
    while datalength(@bm) < @bytenum
        set @bm = @bm + 0x00

    SET @oldbyte = SUBSTRING( @bm, @bytenum, 1)
    IF @oldbyte IS NULL SET @oldbyte = 0
    if @toset <> 0
        SET @newbyte = @oldbyte | @mask
    else
        SET @newbyte = @oldbyte & @mask

    if (@bytenum = 1)
        set @bm = convert(binary(1), @newbyte) + substring(@bm, 2, 127)
    else
        set @bm = substring(@bm, 1, @bytenum - 1) + convert(binary(1), @newbyte) + substring(@bm, @bytenum + 1, 128 - @bytenum)

 
Last revision 2008RTM
See also

  sp_mergearticlecolumn (Procedure)
sp_MSaddguidindex (Procedure)
sp_MSaddupdatetrigger (Procedure)
sp_MSfillupmissingcols (Procedure)
sp_MSfillup_deleted_cols (Procedure)
sp_MSgetmissingbm (Procedure)
sp_MSmerge_altertable (Procedure)
sp_MSset_timestamp_bm (Procedure)
sp_repldropcolumn (Procedure)
sp_vupgrade_mergetables (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
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
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash