SQL Server Performance

Adding a bit field to a view

Discussion in 'SQL Server 2008 General DBA Questions' started by darkangelBDF, Feb 9, 2010.

  1. darkangelBDF Member

    Hi there. all. I've been assigned a change request asking me to add a bit field to a few views but only to the views. My question is if this field does not exist in a table how can I hard-code it into a view? I hope this makes sense. In summary:
    I have existing views.
    I need to add the same field to all four these views.
    It will be a bit field.
    It does not exist on any of the tables the views refer to.
  2. FrankKalis Moderator

    Not sure I understand you correctly, but you could always do something like
    SELECT ....., CAST(1 AS bit)
    but this request seems to be strange. This is a constant and therefore could just as well be added on the client side.
    Otherwise, if the column does not exist in any table, you can not refer to it in any view or other object, for that matter.
  3. Adriaan New Member

    Just guessing, but probably the value will be derived using a CASE statement, based on specific column values, or it will be a lookup to a bit column on a reference table which is an attribute for a foreign key.
  4. Madhivanan Moderator

    Can you give more informations so that we dont need to guess what you really want?

Share This Page