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.
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=TrueWhere ID=1But this works:Update Table Set BitField=1Where ID=11) 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 FORselect name from sysobjects where type = 'U' and name <> 'dtproperties' order by nameOPEN Table_CursorFETCH NEXT FROM Table_CursorINTO @TableNameWHILE @@FETCH_STATUS = 0BEGIN--****************************************************************DECLARE Query_Cursor CURSOR FORSELECT 'Alter table '+@TableName collate SQL_Latin1_General_CP1_CI_AS+' Alter column '+ sy.name + ' '+ ms.Name +'('+ cast(sy.length as varchar(20)) +') '+@collation as _qryFROM dbo.syscolumns syjoin master..systypes ms onms.xType = sy.xTypewhere id = OBJECT_ID(@TableName) and ms.Name = 'varchar'OPEN Query_CursorFETCH NEXT FROM Query_CursorINTO @qryWHILE @@FETCH_STATUS = 0BEGINprint @qryprint 'GO'FETCH NEXT FROM Query_Cursor INTO @qryENDCLOSE Query_CursorDEALLOCATE Query_Cursor--******************************************************************FETCH NEXT FROM Table_Cursor INTO @TableNameENDCLOSE Table_CursorDEALLOCATE Table_CursorGori! |
|
|
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=TrueWhere ID=1But this works:Update Table Set BitField=1Where ID=11) 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 MVPhttp://visakhm.blogspot.com/ |
|
|
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 FORselect name from sysobjects where type = 'U' and name <> 'dtproperties' order by nameOPEN Table_CursorFETCH NEXT FROM Table_CursorINTO @TableNameWHILE @@FETCH_STATUS = 0BEGIN--****************************************************************DECLARE Query_Cursor CURSOR FORSELECT 'Alter table '+@TableName collate SQL_Latin1_General_CP1_CI_AS+' Alter column '+ sy.name + ' '+ ms.Name +'('+ cast(sy.length as varchar(20)) +') '+@collation as _qryFROM dbo.syscolumns syjoin master..systypes ms onms.xType = sy.xTypewhere id = OBJECT_ID(@TableName) and ms.Name = 'varchar'OPEN Query_CursorFETCH NEXT FROM Query_CursorINTO @qryWHILE @@FETCH_STATUS = 0BEGINprint @qryprint 'GO'FETCH NEXT FROM Query_Cursor INTO @qryENDCLOSE Query_CursorDEALLOCATE Query_Cursor--******************************************************************FETCH NEXT FROM Table_Cursor INTO @TableNameENDCLOSE Table_CursorDEALLOCATE Table_CursorGori!
Humm, It's a BIT column not a VARCAHRBut, to the OP.. No you have to use 1 or 0. The True or False is just how that program displays bit values. |
|
|
|
|
|
|
|