Using Table valued function

  • I have a scenario in which i need to get through different values (table) returned from The function and use this function to join with table??

    Is that possible??

  • That is possible.Are you going to call the function for each row in the table?Or are you trying to join the output of the function (where the output of function is independent of the data in the joining table) with table?

    GulliMeel

    Finding top n Worst Performing queries[/url]
    Improve the performance of Merge Join(special case)
    How to Post Performance Problem -Gail Shaw[/url]

  • it depends. way to vague to really answer. can you post a more detailed explanation and some DDL, Sample data, and expected results?

    See the first link in my signature for the best way to post the DDL and Sample data.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]

    Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
    Jeff Moden's Cross tab and Pivots Part 1[/url]
    Jeff Moden's Cross tab and Pivots Part 2[/url]

  • Yes, I am trying to join the output of the function (where the output of function is independent of the data in the joining table) with table?

    example

    I have a function passing some values which will return startdate, end date , completed time and the step_name and ID

    and I need to join that Id with the Main table to get some other values in my result.

    Can you give some example of syntax??? How to write this in SQL or any link??

  • komal145 (7/3/2012)


    Yes, I am trying to join the output of the function (where the output of function is independent of the data in the joining table) with table?

    example

    I have a function passing some values which will return startdate, end date , completed time and the step_name and ID

    and I need to join that Id with the Main table to get some other values in my result.

    Can you give some example of syntax??? How to write this in SQL or any link??

    You are going to have to show us what you are trying to accomplish. Please provide the DDL for the tables and functions involved, sample data for the tables, and expected output you'd like to see based on the sample data you provide.

  • CELKO (7/3/2012)


    The short answer is that good programmers do not use table valued functions. They are proprietary, screw up the optimizer and require disk access so they are slow.

    Instead we have derived tables. VIEWs and CTEs which are portable, faster and can be optimized.

    Good programmers, meaning those that adhere to your principles of writing nothing but STANDARD SQL code, and avoiding ALL dbms specific features even if using those features can provide improved performance and scalability.

    Use the tools you have available and learn to use them right. It isn't like you change DBMS's like you change light bulbs or anything like that.

  • CELKO (7/3/2012)


    The short answer is that good programmers do not use table valued functions. They are proprietary, screw up the optimizer and require disk access so they are slow.

    Instead we have derived tables. VIEWs and CTEs which are portable, faster and can be optimized.

    Celko that's a plain, shortsighted answer, and very misleading on a SQL Server specific forum. Good programmers use the best most efficient tools available for the task on hand.

    you cannot say don't use proprietary stuff, and then in the same sentence say that the SQL Server proprietary optimizer will not handle it correctly.

    that's just incorrect and you should know better.

    Like any method, a table value function can be misused or written incorrectly, the same as a a CTE, view or derived table as well.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 7 posts - 1 through 6 (of 6 total)

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