title: SQL Executing Stored Procedures based on conditional logic - How do I have paramaters in the Procedure as the checks for the conditon?
body: <p>I have the following statement below:</p>
  
  <pre><code>if dbo.TableExists('table') = 1 
  and dbo.columnexists('table', 'column') = 1
  BEGIN
  EXEC sys.sp_addextendedproperty 
  @name = N'MS_Description', @value = N'someString',
  @level0type = N'SCHEMA', @level0name = 'dbo',
  @level1type = N'TABLE',  @level1name = 'table',
  @level2type = N'COLUMN',  @level2name = 'column';
  END
  </code></pre>
  
  <p>This should effectively only execute the stored procedure based on if the table exists and the column exists; this code is called from a C# application that programmatically passes through the variables in the stored procedure through string formatting etcetera.</p>
  
  <p>I only want this procedure to run on the condition that the table and the column having an extended property added to it both exist.</p>
  
  <p>However, the parameters being passed through to TableExists() and columnexists() only exist in the scope of the procedure, I believe, which is obviously executed after the condition. My question is, how can I pass through the values in '@level1name' and '@level2name' as the checks?</p>