D
D
Dmitry2022-02-07 20:24:15
SQL Server
Dmitry, 2022-02-07 20:24:15

Is it possible to add a tick to the logic (true = ✓ ,false = " ")?

Is it possible to add a tick to the logic (true = ✓ ,false = " ")?

CREATE TABLE Orders 
(
    OrderDate Date not null,
    CompletionDate Date not null,
    PartOfPayment MONEY not null,
    --PaymentSign
    --CompletionSign
    TotalCost MONEY not null,
    TermTotalGuarantee Date not null,
)

PaymentSign and CompletionSign (there is a payment - a tick, there is no payment - empty)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2022-02-07
@roflanPominki

What is "add a tick to the logic"?
Sql Server is not responsible for presenting the data - your application should do it.
In it, you can at least draw a checkmark, even draw crosses.
If we are talking about a logical data type, then in Sql Server bit is used for this (takes values ​​0 and 1)
https://docs.microsoft.com/en-us/sql/t-sql/data-ty...
Specifically according to your scheme, but it will be:

CREATE TABLE Orders 
(
    -- ...
    PaymentSign BIT NOT NULL,
    CompletionSign BIT NOT NULL
    -- ...
);

R
rPman, 2022-02-07
@rPman

there is a bool or boolean type, see the documentation for your database the
vast majority of programming languages ​​or database frameworks perceive the integer 0 as false, and 1 as true (often true - any other number)
there is another approach, null - false, any other value is true, but I remember there were situations (and not in any database) that empty values ​​did not get into the index, and working with them was inefficient, and although it was a long time ago .. the sediment remained
And of course there are enumerated types - enum, define your values ​​for true/false, but the implementation in different databases is different, some store string values ​​as they are, while others store numeric values, according to the description of the enum type

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question