?
Solved

SQL Server BIT field true and false

Posted on 2009-12-24
2
Medium Priority
?
522 Views
Last Modified: 2012-05-08
I have a field in a  table in sql server it is of type BIT

I am trying to do an insert in  a stored procedure

BEGIN

INSERT INTO dbo.AccessCodes
(
      AccessCode,
      CodeType,
    Active,
      Assigned
)
VALUES
(
   @AccessCode,
   @BillingMethod,
   true
)
END

I get an error message

The name "true" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

I went with 1 and 0

BEGIN

INSERT INTO dbo.AccessCodes
(
      AccessCode,
      CodeType,
    Active
)
VALUES
(
   @AccessCode,
   @BillingMethod,
   1
)
END

Later I want to query

select * from accesscodes where active =false
and get

Invalid column name 'false'.

The column is definitly bit

CREATE TABLE [dbo].[AccessCodes](
      [AccessCode] [varchar](10),
      [CodeType] [varchar](1),
      [Active] [bit] NULL,
....
....
)

What am I doing wrong?  I did try UPPERCASE TRUEand FALSE as well



0
Comment
Question by:Charles Baldo
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 26119562
the bit column can store onlu 1/0 and Nulls ... so you have to use 1 for true and 0 for false
select * from accesscodes where active =0
0
 

Author Closing Comment

by:Charles Baldo
ID: 31669795
Thanks
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question