![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Consider the following table Customer custId char(10) accountExpiryDate datetime accountStatus bit Now, I want to update the accountStatus to False as soon as the current date becomes accountExpiryDate. I think it can be done using "SQL Agent" but my webhost doesnt provide me access to that. I have access only to the Query Analyzer. Thanks Shane |
#3
| |||
| |||
|
|
Consider the following table |
|
accountExpiryDate datetime accountStatus bit Now, I want to update the accountStatus to False as soon as the current date becomes accountExpiryDate. I think it can be done using "SQL Agent" but my webhost doesnt provide me access to that. I have access only to the Query Analyzer. Thanks Shane |
#4
| |||
| |||
|
|
Consider the following table |
|
Now, I want to update the account_status to FALSE as soon AS the current date becomes accountexpiry_date. |
#5
| |||
| |||
|
|
Notice I dropped the redundant BIT column. Some newbie actually used a proprietary, low-level BIT data type. You need to fix that at once and teach the guy that SQL has no BOOLEAN data types -- that is just sooooo fundamental! |
|
CREATE VIEW ActiveCustomers (..) AS SELECT cust_id, acctexpiry_date, .. FROM Customers WHERE CURRENT_TIMESTAMP < acctexpiry_date; |
#6
| |||
| |||
|
|
Consider the following table Customer custId char(10) accountExpiryDate datetime accountStatus bit Now, I want to update the accountStatus to False as soon as the current date becomes accountExpiryDate. I think it can be done using "SQL Agent" but my webhost doesnt provide me access to that. I have access only to the Query Analyzer. |
#7
| ||||
| ||||
|
|
CREATE TABLE Customers -- plutal names for sets, please ( cust_id char(10) Thanks again from the "newbie" |
|
You need to fix that at once and teach the guy that SQL has no BOOLEAN data types -- that is just sooooo >fundamental! Did not know that. |
|
Yes and no. It's optional, so *of course* every major implementation deals with it differently. http://troels.arvin.dk/db/rdbms/#data_types-boolean To CELKO : Would want your comments on this for "MS SQL Server" |
|
Change accountStatus to accountStatus AS (CASE WHEN accountExpirydate < getdate() THEN convert(bit, 1) ELSE convert(bit, 0) END) |

#8
| |||
| |||
|
|
Did not know that. |
|
To CELKO:- You could have conveyed the message better by being a less rude |
#9
| |||
| |||
|
|
All data types have to be NULL-able in SQL. Having a BOOLEAN type would lead to 4 valued logic with inconsistent rules about how NULLs propagate. And the various vendor extension do not work or port either. |
#10
| |||
| |||
|
|
--CELKO-- wrote: All data types have to be NULL-able in SQL. Having a BOOLEAN type would lead to 4 valued logic with inconsistent rules about how NULLs propagate. And the various vendor extension do not work or port either. It seems like dropping UNKNOWN would leave a sensible set of rules: and | T N F or | T N F not | ----+------ ---+------ ----+-- T | T N F T | T T T T | F N | N N F N | T N N N | N F | F F F F | T N F F | T Am I overlooking anything? |
![]() |
| Thread Tools | |
| Display Modes | |
| |