Solved

MS SQL: bit-datatype: where can I set the string-values?

Posted on 2013-01-10
9
449 Views
Last Modified: 2013-01-16
Hi

if I make a query with a bit datatype I get the values "true" or "false". In some installation I get "wahr" and "falsch" (german). Where can I set which values I want to get or where can I read the actual set values?
0
Comment
Question by:formi
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 22

Expert Comment

by:Om Prakash
ID: 38762664
Bit is an integer data type that can take a value of 1, 0, or NULL.

The string values TRUE and FALSE can be converted to bit values: TRUE is converted to 1 and FALSE is converted to 0.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38762693
I presume it's the front-end application's (or OS) "language" setting that determines if the 1/0 is "translated" to true/false or something else.
this cannot be controlled on sql server side.

so, the question resolves to: how do you actually display the values?
0
 

Author Comment

by:formi
ID: 38762719
Thanks for aour suggestions. I have to tell you more where my problem is: I use a tDbGrid-component from TMS-Software where one can use checkboxes in the grid. In the component's columns there is a property CheckTrue and CheckFalse where one can define which string-value refers to 0 or 1. I tried to add '0' and '1' but this doesn't work. One has to define the string-values (in my case "falsch" and "wahr".

@angelIII: the station where the values are displayed in english is also a german OS, maybe the problem is on a multilanguage-OS??
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38762730
sorry, I don't know that component, so I don't know how to troubleshoot the grid's behavior...
0
 
LVL 41

Expert Comment

by:ralmada
ID: 38762893
have you tried setting DBAdvGrid.Columns[numericfieldindex].CheckBoxField = true

As per the tms manual:

Example:
Assume that an Interbase numeric field stores 1 as true condition and 0 as false condition. We want
to display & edit this field with a checkbox. As the DB field type is ftNumeric, setting
DBAdvGrid.ShowBooleanFields will not show this field as checkboxes. Setting
DBAdvGrid.Columns[numericfieldindex].CheckBoxField = true will show checkboxes and the checked
state of the checkbox is controlled with DBAdvGrid.Columns[numericfieldindex].CheckTrue = ‘1’ and
DBAdvGrid.Columns[numericfieldindex].CheckFalse = ‘0’.

http://www.tmssoftware.com/site/manuals/TMS%20TDBAdvGrid.pdf
0
 

Author Comment

by:formi
ID: 38763482
Yes I did it. The strange behavior is that it works on my pc but not on a customers pc (many grids with checkboxes but only all checkbox in one grid don't work!

Hi

I have multiple tDbAdvGrids with checkboxes with the following settings:

grid.columns[x].CheckboxField := true;
grid.columns[x].CheckFalse := 'falsch';
grid.columns[x].CheckTrue := 'wahr';
grid.columns[x].Editor := edCheckbox;

I ask in the TMS forum and hope I can get some help.
0
 
LVL 41

Expert Comment

by:ralmada
ID: 38763631
grid.columns[x].CheckboxField := true;
grid.columns[x].CheckFalse := 'falsch';
grid.columns[x].CheckTrue := 'wahr';

I think it should be:

grid.columns[x].CheckboxField := true;
grid.columns[x].CheckFalse := '0';
grid.columns[x].CheckTrue := '1';

that way you don't have to worry about the language. Remember that in SQL store 1 for True and 0 for False, regardless on how it is displayed.
0
 

Accepted Solution

by:
formi earned 0 total points
ID: 38766940
Sorry it was my mistake (as usual :-): the datatype was integer and not boolean. oevery thing is ok.

Regards and thanks, Peter
0
 

Author Closing Comment

by:formi
ID: 38781943
found the solution myself (see above)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

840 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