User Defined Functions vs Stored Procedures

  • Dear Forum,

    I've recently discovered user defined functions (UDFs) and find them very useful for calculating new variables and putting views in.

    I've read about stored procedures (SPs) which seem to be similar in the way they are written.

    However, I haven't been able to find information about when to use a UDF or a SP.

    Are there situations where it is much more appropriate to use a UDF over a SP?

    Is this a gey area?

    Are SPs faster but harder to write?

    Thanks, Bill

  • There is no magic about udf's or stored procedures

    create procedure showsp

    as

    select * from ::fn_helpcollations()

    go

    exec showsp

    drop procedure showsp

    But as this is a very broad topic, I suggest to first take a look at BOL for both.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

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