• rho_pooka (1/11/2014)


    Greetings! On chapter four looking at inline table valued functions. Can someone translate this code into English? I see this at the beginning of a lot of code posted in the forum, and now in the 70-461 book, but have a hard time deciphering it. I don't understand the 'IF' in the parentheses nor the "IS NOT NULL DROP"

    IF OBJECT_ID('HR.GetManagers', 'IF') IS NOT NULL DROP FUNCTION HR.GetManagers;

    GO

    CREATE FUNCTION HR.GetManagers(@empid AS INT) RETURNS TABLE

    AS

    RETURN

    .....--goes on to create CTE

    As I read it, it looks like:

    If HR.GetManagers, or IF (why if?) exists, delete them, and create a new HR.Getmanagers function that requires an input of @empid that is an INT. Once putting in the INT for @empid, the function will use it help create a CTE, then I can query the CTE. Is that close?

    Although it may seem so, I'm not being sarcastic at all when I ask you, do you know what "Books Online" is? People who ask the kinds of questions that you've just asked usually have no clue what it is and it's a huge help even for an old salt like me.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)