• tz.bahrami (12/27/2012)


    Thanks for your instruction, i am familiar with junction table, but i look a way to implement something like inheritance. In addition i agree with you for encapsulating by stored procedures.

    Your request still doesn't make sense. If you MUST think of sql as objects think of the table as the object and each row as the instance and each column is the property. What you are describing is you want to inherit the row. This doesn't make sense because in OOP that would be like inheriting the properties of an instance. It doesn't work like that. You inherit the object.

    I think that what you are really trying to do is to have a parent - child relationship in sql. This of course is not only possible, it is a fundamental base for normalized data.

    Is the following example something along the lines of what you talking about?

    create table #Parent

    (

    ParentID int identity,

    SomeValue varchar(10)

    )

    create table #Child

    (

    ChildID int identity,

    ParentID int,

    SomeValue varchar(10)

    )

    insert #Parent

    select 'Parent 1' union all

    select 'Parent 2'

    insert #Child

    select 1, 'Child 1' union all

    select 1, 'Child 2' union all

    select 2, 'Child 3' union all

    select 2, 'Child 4' union all

    select 2, 'Child 5'

    select *

    from #Parent p

    join #Child c on p.ParentID = c.ParentID

    drop table #Parent

    drop table #Child

    _______________________________________________________________

    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/