Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 bit datatype displaying true/false in mnge studio

Author  Topic 

SQLIsTheDevil
Posting Yak Master

177 Posts

Posted - 2009-09-30 : 16:22:40
Hello all,

I have a question regarding the datatype bit. I'm using SQL Server 2000, which seems obvious to say on this forum, but it's important to remember, perhaps. In SQL Server Enterprise Manager and SQL Query Analyzer, it displays 1 or 0. However, if I use SQL Server Management Studio, I see that it displays True or False. And, yet, this fails:

Update Table Set BitField=True
Where ID=1

But this works:

Update Table Set BitField=1
Where ID=1

1) Why is one program displaying 1/0 and the other is displaying True/False?

2) Can I insert/update fields of datatype bit using true/false, in addition to 1/0? That is, are both queries possible?

Thank you!

Gori
Starting Member

1 Post

Posted - 2010-08-15 : 04:00:05
Hi,

The easiest way to change the default collation is to rebuild the master db and then run the following query, in order to apply the changes on all tables:

Declare @TableName varchar(1000)
Declare @qry varchar(8000)
Declare @collation Varchar(200)
set @collation = 'COLLATE SQL_Latin1_General_CP1_CI_AS'


DECLARE Table_Cursor CURSOR FOR
select name from sysobjects where type = 'U' and name <> 'dtproperties' order by name
OPEN Table_Cursor
FETCH NEXT FROM Table_Cursor
INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
--****************************************************************
DECLARE Query_Cursor CURSOR FOR
SELECT 'Alter table '+@TableName collate SQL_Latin1_General_CP1_CI_AS+' Alter column '+ sy.name + ' '+ ms.Name +'('+ cast(sy.length as varchar(20)) +') '+@collation as _qry
FROM dbo.syscolumns sy
join master..systypes ms on
ms.xType = sy.xType
where id = OBJECT_ID(@TableName) and ms.Name = 'varchar'

OPEN Query_Cursor
FETCH NEXT FROM Query_Cursor
INTO @qry
WHILE @@FETCH_STATUS = 0
BEGIN
print @qry
print 'GO'

FETCH NEXT FROM Query_Cursor INTO @qry
END
CLOSE Query_Cursor
DEALLOCATE Query_Cursor
--******************************************************************

FETCH NEXT FROM Table_Cursor INTO @TableName
END
CLOSE Table_Cursor
DEALLOCATE Table_Cursor


Gori!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-15 : 04:33:05
quote:
Originally posted by SQLIsTheDevil

Hello all,

I have a question regarding the datatype bit. I'm using SQL Server 2000, which seems obvious to say on this forum, but it's important to remember, perhaps. In SQL Server Enterprise Manager and SQL Query Analyzer, it displays 1 or 0. However, if I use SQL Server Management Studio, I see that it displays True or False. And, yet, this fails:

Update Table Set BitField=True
Where ID=1

But this works:

Update Table Set BitField=1
Where ID=1

1) Why is one program displaying 1/0 and the other is displaying True/False?

2) Can I insert/update fields of datatype bit using true/false, in addition to 1/0? That is, are both queries possible?

Thank you!


where its displaying as True/False? is it in normal query window or in cube browser?
nope. bit fields available values are 1 and 0 so you need to use the same for inserting

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-08-19 : 11:57:22
quote:
Originally posted by Gori

Hi,

The easiest way to change the default collation is to rebuild the master db and then run the following query, in order to apply the changes on all tables:

Declare @TableName varchar(1000)
Declare @qry varchar(8000)
Declare @collation Varchar(200)
set @collation = 'COLLATE SQL_Latin1_General_CP1_CI_AS'


DECLARE Table_Cursor CURSOR FOR
select name from sysobjects where type = 'U' and name <> 'dtproperties' order by name
OPEN Table_Cursor
FETCH NEXT FROM Table_Cursor
INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
--****************************************************************
DECLARE Query_Cursor CURSOR FOR
SELECT 'Alter table '+@TableName collate SQL_Latin1_General_CP1_CI_AS+' Alter column '+ sy.name + ' '+ ms.Name +'('+ cast(sy.length as varchar(20)) +') '+@collation as _qry
FROM dbo.syscolumns sy
join master..systypes ms on
ms.xType = sy.xType
where id = OBJECT_ID(@TableName) and ms.Name = 'varchar'

OPEN Query_Cursor
FETCH NEXT FROM Query_Cursor
INTO @qry
WHILE @@FETCH_STATUS = 0
BEGIN
print @qry
print 'GO'

FETCH NEXT FROM Query_Cursor INTO @qry
END
CLOSE Query_Cursor
DEALLOCATE Query_Cursor
--******************************************************************

FETCH NEXT FROM Table_Cursor INTO @TableName
END
CLOSE Table_Cursor
DEALLOCATE Table_Cursor


Gori!

Humm, It's a BIT column not a VARCAHR

But, to the OP.. No you have to use 1 or 0. The True or False is just how that program displays bit values.
Go to Top of Page
   

- Advertisement -