Microsoft
Software
Hardware
Network
Question : SQL Server BIT field true and false
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
Answer : SQL Server BIT field true and false
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
Random Solutions
Upgrade to Server 2008 Enterprise Error "Not enough free space for temporary files", even with plenty of space.
What does the error message mean that says that a name conflicts with a valid range reference?
move default mailboxes ?
Get Year from Date in SQL Statement
How do i pass data from one listbox to another listbox in vba.
Out of memory or system resources. Close some windows or programs and try again.
how to log on as adminiatrator MS Word 2007 Vista
Access VB and PCAnywhere 10.5 OLE File Transfer Automation
Find \Device\Harddisk1\Partitio<wbr />n1 in Windows NT 4.0 (bad sectors)
SSRS - MultiValue Param - distinct?