Thread: Toggle a Bit type ie not field

Toggle a Bit type ie not field

From
"Peter Morgan"
Date:
Here's the SP that toggles a Bit datatype. How would I make it comething
like
???
update pcpmanufacturers set def = not (def) where ManufID = @ManufID

----------------------------------------------------------------------
create Procedure pcp_manufToggle
@ManufID int

as

Set nocount on

declare @S as bit
select @s = def from pcpManufacturers where ManufID = @ManufID

if (@s = 1) begin
update pcpManufacturers set def=0 where manufID = @ManufID
end
else beginupdate pcpmanufacturers set def=1 where manufid = @manufID
end

TIA

Pete





Re: Toggle a Bit type ie not field

From
Brent Verner
Date:
On 20 Mar 2001 at 23:07 (-0000), Peter Morgan wrote:
| Here's the SP that toggles a Bit datatype. How would I make it comething
| like
| ???
| update pcpmanufacturers set def = not (def) where ManufID = @ManufID

update pcpmanufacturers set def=(1-def) where ManufID=@ManufID;

hth.brent

-- - - - - - - - -=(   d a m o n   b r e n t   v e r n e r   )=- - - - - - - - -               c e r t i f i e d   n o
so u r c o p h o b i c