Debug T-Sql

Hi ,

     I have a Function in Sql Server (2008 R2)  . But there is something wrong  when I call the function

      But how can I debug the function  .. PASSING THE INPUT PARAMETERS

      My function name is GetRelObj and  is there a way I can debug  by calling a it in a query
      something   like  
        Select   GetRelOBJ (obj.ID , 'Newface','12' ,'','')  from SOBJ OBJ  where obj.DEFID = 'Class'  

      Infact If I can debug the function by passing the input parameters  , that is good enough

    Thanks

      Sam
Sam OZAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PortletPaulfreelancerCommented:
what happens if you try this?

Select   GetRelOBJ (obj.ID , 'Newface','12' ,'','')  from SOBJ OBJ  where obj.DEFID = 'Class'  

or this?

Select   GetRelOBJ (100 , 'Newface','12' ,'','')

without any access to the function itself, it's hard to suggest much
0
Vikas GargBusiness Intelligence DeveloperCommented:
Hi,

You can debug in UDF function using SSMS

select * from [dbo].[CommaSeparatedToTable]('he,loo',',')
Click on Debug and then press F11 step by step it will take you to the Function and return values for it.

you can also follow this link which would let you know something about UDF debugging

http://www.novicksoftware.com/UDFofWeek/Vol2/T-SQL-UDF-Vol-2-Num-8-debugging-udfs.htm

Hope this will help you
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sam OZAuthor Commented:
Hi PortletPaul /Other Experts,

      The issue looks fairly simple .. It is  just  me being too naive with T-Sql ,

 #  How I  check if a value is null ( actually check for '')  . I tried
       if  @PWF  <> ''    
   But it doesn't  look like the right one ( Though there is no syntax error)
         

##        Can I really have optional  input parameters  ( I have  5 input parameters , can I make last two optional with a default value ?)

   Thanks

       Sam
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Vikas GargBusiness Intelligence DeveloperCommented:
Hi,

You can have optional parameter for that you can pass value inside the function if you want and while calling the function you have to write default in place of value

select * from [dbo].[CommaSeparatedToTable]('he,loo',default) which accepts two parameter but for second i have assigned default which I dont want to pass from outside
0
Sam OZAuthor Commented:
Hi Vikas,

     Can you please elaborate ?
   
            If I take your example
                    CommaSeparatedToTable   has two input parameters   and second one is optional

               So Can I call this function as
         
                    dbo.CommaSeparatedToTable ('heloo')
0
Vikas GargBusiness Intelligence DeveloperCommented:
No,

Second is option so if you want to pass value then you have to write like

dbo.CommaSeparatedToTable ('heloo',',')

And if you dont want to pass the second parameter then write like

dbo.CommaSeparatedToTable ('heloo',default)

So it will take the default value if you have mentioned during Function creation
0
Sam OZAuthor Commented:
Then that won't help me much ..But thanks for the Defualt option

   Also can you please look my  first question

    #  How I  check if a value is null ( actually check for '')  . I tried
       if  @PWF  <> ''    
   But it doesn't  look like the right one ( Though there is no syntax error)
0
Vikas GargBusiness Intelligence DeveloperCommented:
You can default pass null to the function parameter while creating the function.

But i am not getting your point for checking the parameter value ...
0
Carl TawnSystems and Integration DeveloperCommented:
Do you actually want to check for NULL, or check for blank?

IF @PWF IS NULL     -- check for NULL

IF @PWF <> ''     -- check for non-blank

Open in new window

Blank and NULL are different things. Blank is an empty value whereas NULL is the absence of a value, so you can't use a check for '' to determine if the value is null.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.