• Weird question.

    I think the key here is 'return certain columns', not return certain rows. A view or function can indeed return different rows based on a pk value, but to return different columns based on a pk value would require dynamic SQL, which neither a view nor a function can use.

    That said, if I saw code from one of my devs which used a table's pk value to decide which columns a procedure should return, they'd be taking their code back to the drawing board, it's a pretty odd thing to do.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass