title: declare variable in a sql function
body: <p>I have a sql  function and i need to declare few variables in that function. Please advise how can i achieve this.</p>
  
  <p>For example i need to put -->  </p>
  
  <pre><code>Declare @ClientResult TABLE(
          RowIndex int identity(1,1),
          SplitText varchar(50) 
      )  
  </code></pre>
  
  <p>in the below function. </p>
  
  <pre><code>create FUNCTION [dbo].CLIENT_SHIPPINGREPORTDATA_Function_Test  
  (                    
   @CLIENTPK_NEW TABLE,
   @CGNEEPK TABLE
   @type varchar(100)              
  )                 
  RETURNS TABLE                    
  AS              
  
  RETURN                 
  
  SELECT   distinct              
  OP_PartNum,            
  OP_PK       
  FROM Client_whsPallet pallet                 
  </code></pre>
  
  <p>I am using sql server 2005</p>
  
  <p>Thanks</p>