Link to home
Start Free TrialLog in
Avatar of Sam OZ
Sam OZFlag for Australia

asked on

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
SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sam OZ

ASKER

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
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
Avatar of Sam OZ

ASKER

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')
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
Avatar of Sam OZ

ASKER

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)
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 ...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial