How we can insert a sign of flag in the record based on condition.?

  • I want to insert a sign or change the color of particular record based on result of the condition.

    for an example if age is more than >45 then all the records in the table which are more than 45 will have some kind of sign or their color shoul get change.

    Please help.

    thanks.

  • You cannot change the "colour" of records in T-SQL. It's up to UI application to format and display results of the query.

    _____________________________________________
    "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]

  • can i put a kind of sign in it.?

  • prtk.raval (5/31/2013)


    can i put a kind of sign in it.?

    Sure.

    case when age > 45 then 'here is a sign' else 'no sign here' end as SomeKindOfSign

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Yep you can, something like

    SELECT ... all you need columns ...

    ,CASE WHEN [condition] THEN 'Red' ELSE 'Black' END as RowColour

    FROM ....

    However, I cannot see real need of this, as you better this put this "condition" check in UI

    _____________________________________________
    "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 am using merge query, i need to indicate that the record is deleted WHEN NOT MATCHED BY THE SOURCE in merge query definition.

    i have one column in my detination table that keep the record of status whether its INSERTE, UPDATED, OR DELETED.

Viewing 6 posts - 1 through 5 (of 5 total)

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