SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 bit datatype displaying true/false in mnge studio
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SQLIsTheDevil
Posting Yak Master

USA
173 Posts

Posted - 09/30/2009 :  16:22:40  Show Profile  Reply with Quote
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

Saudi Arabia
1 Posts

Posted - 08/15/2010 :  04:00:05  Show Profile  Reply with Quote
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

India
52249 Posts

Posted - 08/15/2010 :  04:33:05  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

4361 Posts

Posted - 08/19/2010 :  11:57:22  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000