title: Adding Parameters to a Stored Procedure in SQL Server
body: <p>I am new to <code>K2</code>and <code>SQL Server</code>. </p>
  
  <p>I want to add a parameter to a stored procedure, which will be later tied to a <code>K2</code> smart object for the respective views and forms.</p>
  
  <p>Currently it takes in 1 parameter, <code>lang</code>, which is an input from a label from the <code>K2</code> Smartform View. </p>
  
  <p>I added a label <code>labelHideInactiveCompany</code> on the same view, and I would like to pass that value into my Stored Procedure but I don't know how to do it.</p>
  
  <p>I am told that the first thing I need to change is the stored procedure, and then updating the <code>smart object</code>. </p>
  
  <p>May I know what are the steps I should be take? Thank you.</p>
  
  <p>Below is my query:</p>
  
  <pre><code>USE [K2_Database]
  GO
  
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  ALTER procedure [Config].[usp_ListBusinessUnit] 
  @lang varchar(2) = null
  as
  
  SELECT EntityId
        ,EntityCode
        ,EntityName
        ,CO.OrganizationDesc
        ,EntityAbbreviation
        ,PBU.ParentBusinessUnitName
        ,EntityAttribute 
        ,EntityOwnedCompany
        ,EntityPrincipal
        ,EntityAccountingProgram 
        ,EntityCurrency
        ,EntityCurrenyExchRate 
        ,BU.CountryRegion
        ,EntityNCOwnedIndustry
        ,BU.IsActive 
        ,BU.CreatedBy 
        ,CreateOn 
        ,BU.ModifiedBy
        ,BU.ModifiedOn 
        ,BU.Lang AS LangAbbr
    FROM Config.BusinessUnit BU
    LEFT JOIN Config.Organization CO on BU.OrganizationId = CO.OrganizationId
    LEFT JOIN Config.ParentBusinessUnit PBU on BU.ParentBusinessUnitId = PBU.ParentBusinessUnitId 
    ORDER BY CASE WHEN @lang = 'cn' THEN BU.Lang END,
             CASE WHEN @lang = 'en' THEN BU.Lang END DESC, 
             EntityName
  </code></pre>