How to debug a User Defined Function

  • Hi All,

    Please post different ways to debug an User Defined Function in SQL Server.

    I'm thinking about is there a way you can debug from SSMS or Query Analyser? I know there is a way to do this from Visual Studio but I'm wondering if this is possible through any SQL tools?

    Thanks.

  • I guess it depends on what's bugged and what version of the database you're using.

    One of my usual ways to debug a UDF is to break it out into a script instead of a function (parameters become variables, return command becomes select), then run it that way.

    In 2000 or 2005, I can add print/raiserror/select commands to check the status of variables, etc., as the script runs. In 2008, I can add check points to it in SSMS.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I can test in Visual Studio (I have SQL Server Express on my machine)

    left click and Step Into User Function or something like that

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

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