Return value if field not there in Query

  • I want to check field/column exist or not in a table and populate the value

    Example: Does the column1,column2 exists:

    case1:return column1 and column2

    case2:return column1 or column2

    case3:return column1

    case4:return column2

    case5:return '0'(no columns)

    How can I achieve this?

  • Your explanation is not very clear enough. What do you mean by return( return a value or a result or a column name or ... )?

    You can use the INFORMATION_SCHEMA.COLUMNS view to check if a particular column exists in a table.


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • tibco29 (9/11/2013)


    I want to check field/column exist or not in a table and populate the value

    Example: Does the column1,column2 exists:

    case1:return column1 and column2

    case2:return column1 or column2

    case3:return column1

    case4:return column2

    case5:return '0'(no columns)

    How can I achieve this?

    I think what you mean is: If column1 exists then populate column1 with a particular value else ignore. Right?

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

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