Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Boolean computed column
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Smokey Grindle  
View profile  
 More options Jul 10 2007, 12:14 pm
Newsgroups: microsoft.public.sqlserver.programming
From: "Smokey Grindle" <nos...@nospam.com>
Date: Tue, 10 Jul 2007 12:14:43 -0400
Local: Tues, Jul 10 2007 12:14 pm
Subject: Boolean computed column
I have a column in my database I want to be a computed flag based on an
active date.. the Flag column is called active..

basicall I want if the ActiveDate <= getdate() (as in today is after the
item was active) then the active flag is a bit 1, else its a bit 0... I
tried this as a flat out <= statement, got an error by SQL Managment
studio... so how would this be done? thanks!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Bertrand [SQL Server MVP]  
View profile  
 More options Jul 10 2007, 12:24 pm
Newsgroups: microsoft.public.sqlserver.programming
From: "Aaron Bertrand [SQL Server MVP]" <ten....@dnartreb.noraa>
Date: Tue, 10 Jul 2007 12:24:38 -0400
Local: Tues, Jul 10 2007 12:24 pm
Subject: Re: Boolean computed column
Why do you need this column stored in the table?  Can't you always derive
that information at query time?

Don't use Management Studio's "design" view to enter the formula.  Try using
a query window, e.g.

ALTER TABLE dbo.MyTable ADD Flag AS CONVERT(BIT, CASE WHEN ActiveDate <=
GETDATE() THEN 1 ELSE 0 END);

However it would be bette to perform this calculation in a view and query
that, instead of "storing" the data, IMHO.

A

"Smokey Grindle" <nos...@nospam.com> wrote in message

news:%23Rnwu1wwHHA.936@TK2MSFTNGP02.phx.gbl...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
--CELKO--  
View profile  
 More options Jul 10 2007, 1:14 pm
Newsgroups: microsoft.public.sqlserver.programming
From: --CELKO-- <jcelko...@earthlink.net>
Date: Tue, 10 Jul 2007 10:14:22 -0700
Local: Tues, Jul 10 2007 1:14 pm
Subject: Re: Boolean computed column
>> I have a column in my database I want to be a computed flag based on an active date.. the Flag column is called active..  basically I want if the ActiveDate <= getdate() (as in today is after the

item was active) then the active flag is a bit 1, else its a bit 0...
I tried this as a flat out <= statement, got an error by SQL
Management studio... so how would this be done? <<

This would be done by forgetting all the basic rules for programming
in SQL :)

1) We do not use the proprietary BIT data type that does not exist in
Standard SQL

2) Flags are for assembly language programming and have no place in
RDBMS; that is why SQL has no BOOLEAN data types

3) We do not store computed columns in a table.  Write a VIEW and
learn to use CURRENT_TIMESTAMP instead of the old proprietary
getdate() function call to get today's active data.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Smokey Grindle  
View profile  
 More options Jul 10 2007, 1:35 pm
Newsgroups: microsoft.public.sqlserver.programming
From: "Smokey Grindle" <nos...@nospam.com>
Date: Tue, 10 Jul 2007 13:35:43 -0400
Local: Tues, Jul 10 2007 1:35 pm
Subject: Re: Boolean computed column
A lot of stuff depends on flags true or false, why would I want to spend
32bits of bandwidth to return a 1 for true if I can do it in 1 bit... as for
other SQL why would I care about that right now either if I am targeting my
program at SQL server only?

"--CELKO--" <jcelko...@earthlink.net> wrote in message

news:1184087662.542002.82480@22g2000hsm.googlegroups.com...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
--CELKO--  
View profile  
 More options Jul 10 2007, 2:55 pm
Newsgroups: microsoft.public.sqlserver.programming
From: --CELKO-- <jcelko...@earthlink.net>
Date: Tue, 10 Jul 2007 11:55:45 -0700
Local: Tues, Jul 10 2007 2:55 pm
Subject: Re: Boolean computed column

>> A lot of stuff depends on flags true or false, why would I want to spend 32 bits of bandwidth to return a 1 for true if I can do it in 1 bit...<<

Why a +1 and not a -1?  Have you compared VB and C# on this issue?  Or
any of the X3J languages?  Since SQL uses 3VL, where is your UNKNOWN
and how do you move it to an application.

In the RDBMS world, true and false are at a "higher level" than the
data -- they refer to predicates about that data and are not part of
it.

An RDBMS person designs data, not just queries.  You will quickly find
that you need a status code that can expand as "yes/no" becomes "yes/
no/not answered/ impossible because of other answers/ etc."  Or you
have one attribute split into "20-questions" with a ton of constraints
to try and co-ordinate them.

>>  as for other SQL why would I care about that right now either if I am targeting my program at SQL server only? <<

Professionalism?  Maintainable and readable code?  "Future Proofing"?
That last one is from Ken Henderson; it means we known that SQL Server
will always be moving toward Standards and not away from them, so
let's avoid problems before they hit us.  For example, the bad
programmers who used BIT got caught when the data type went from (0/1)
to (0/1/NULL) as an exact numeric data type.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Smokey Grindle  
View profile  
 More options Jul 10 2007, 3:21 pm
Newsgroups: microsoft.public.sqlserver.programming
From: "Smokey Grindle" <nos...@nospam.com>
Date: Tue, 10 Jul 2007 15:21:52 -0400
Local: Tues, Jul 10 2007 3:21 pm
Subject: Re: Boolean computed column
What is a bit data type in SQL Server to be used for then? It has to be
there for some reason... Even MS uses the bit type to store true and false
and even encourages it in the .NET SDK with ADO.NET...

"--CELKO--" <jcelko...@earthlink.net> wrote in message

news:1184093745.555791.208230@57g2000hsv.googlegroups.com...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Smokey Grindle  
View profile  
 More options Jul 10 2007, 4:02 pm
Newsgroups: microsoft.public.sqlserver.programming
From: "Smokey Grindle" <nos...@nospam.com>
Date: Tue, 10 Jul 2007 16:02:58 -0400
Local: Tues, Jul 10 2007 4:02 pm
Subject: Re: Boolean computed column
sorry if I sound mad or anything, just gets frustrating when one group of
people teaches you to do something one way then another says no no :)

"--CELKO--" <jcelko...@earthlink.net> wrote in message

news:1184093745.555791.208230@57g2000hsv.googlegroups.com...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
--CELKO--  
View profile  
 More options Jul 12 2007, 11:39 pm
Newsgroups: microsoft.public.sqlserver.programming
From: --CELKO-- <jcelko...@earthlink.net>
Date: Thu, 12 Jul 2007 20:39:38 -0700
Local: Thurs, Jul 12 2007 11:39 pm
Subject: Re: Boolean computed column

>>  What is a bit data type in SQL Server to be used for then? It has to be there for some reason... Even MS uses the bit type to store true and false and even encourages it in the .NET SDK with ADO.NET... <<

It is there for historial reasons.  Sybase/SQL Server grew up before
the Standards and was written for 16 bit hardware on a UNIX platform
decades ago.

The main purpose today, now that we understand RDBMS better, is to
lock you into their products.

I do not care about .NET and ADO, or other proprietary front ends for
applications.  I am the database guy and I write an RDBMS that can
work with any front end.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Damien  
View profile  
 More options Jul 13 2007, 3:27 am
Newsgroups: microsoft.public.sqlserver.programming
From: Damien <Damien_The_Unbelie...@hotmail.com>
Date: Fri, 13 Jul 2007 00:27:21 -0700
Local: Fri, Jul 13 2007 3:27 am
Subject: Re: Boolean computed column
On Jul 13, 4:39 am, --CELKO-- <jcelko...@earthlink.net> wrote:
[snip]

> I do not care about .NET and ADO, or other proprietary front ends for
> applications.  I am the database guy and I write an RDBMS that can
> work with any front end.

So why do you continually harp on about the (no longer existent)
differences in interpretation of bit/boolean by VB and C#? Surely you
shouldn't be worrying about such issues?

Damien


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google