Code Warriors,

I need to set a value in my SQL database as (1 or 0 ) (true or false) so that when i click a button to insert into the database the column register 1 and when i click the button delete the column register 0.

do any warrior have a clue kindly help..

Recommended Answers

All 2 Replies

what exactly you are trying to do ?

Use the bit datatype for boolean. Valid values are 0 or 1. In the below example, Active is the bit column with a default value of 1 (true).

CREATE TABLE ActiveUsers (UserId int NOT NULL, Active bit NOT NULL default 1)

/*Register User*/
INSERT ActiveUsers (UserId) VALUES (123) --Whatever the userid is. Active will be set to 1 because that's the default value.

/*Delete User*/
UPDATE ActiveUsers SET Active = 0 WHERE UserId = 123
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.