Is Flag in SQL sever

  • Hi I wanna add IsEllgible flag to this table

    what data type should I use and sytax

    this is for nvarchar

    ALTER TABLE [dbo].[GetPageData]

    ADD COLUMN PreviewContent [nvarchar](4000) null

    GO

    Please send me the code for Flag thing

  • Hey,

    i guess the field "IsEllgible" is supposed to conaint values for true and false. Therefore i would recommend a bit field.

    Syntax should be

    ADD COLUMN IsElligible bit null

  • moz987 (9/12/2014)


    Hey,

    i guess the field "IsEllgible" is supposed to conaint values for true and false. Therefore i would recommend a bit field.

    Syntax should be

    ADD COLUMN IsElligible bit null

    The above also will allowed NULL, which could be treated as UNKNOWN or else.

    If you want to restrict to True/False only, define your column as non-null eg:

    ADD COLUMN IsElligible bit not null

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • I would suggest the NOT NULL constraint as Eugene mentioned, but I would also add a DEFAULT to it.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply