title: Creating BigQuery Stored Procedure by passing column and table name as parameters
body: <p>I am trying to create BigQuery stored Procedure  that will accept column and Table name as parameters.
  This is the running Query:</p>
  <pre><code>EXECUTE IMMEDIATE (
   ''' SELECT 
           ''' || (SELECT STRING_AGG(DISTINCT &quot;MAX(IF(PROPERTY_KEY = '&quot; || PROPERTY_KEY || &quot;', a.RANK, NULL)) AS &quot; || PROPERTY_KEY)
                  FROM `project.dataset.table` x
                  )  || ''' 
      FROM   (
            select &quot;1&quot; AS GroupbyCol,
                    PROPERTY_KEY , 
                    rank() over (order by PROPERTY_KEY ) AS RANK 
            from (
                  select distinct PROPERTY_KEY 
                  from `project.dataset.table`
                ) 
         ) a GROUP BY GroupbyCol 
  ''') 
  </code></pre>
  <p>I tried creating stored procedure as below:</p>
  <pre><code>CREATE OR REPLACE PROCEDURE `project.dataset.test_stored_procedure_ne`
  (table_name STRING, 
  destination_table STRING, 
  row_ids STRING, 
  pivot_col_name STRING, 
  pivot_col_value STRING, 
  aggregation STRING)
  
  BEGIN
    DECLARE header STRING;
      EXECUTE IMMEDIATE (
  &quot;SELECT 
           ''' || (SELECT STRING_AGG(DISTINCT &quot;MAX(IF(@pivot_col_name = '&quot; || @pivot_col_name || &quot;', a.RANK, NULL)) AS &quot; || @pivot_col_name)
                  FROM `table_name` x
                  )  || ''' 
      FROM   (
            select &quot;1&quot; AS GroupbyCol,
                    @pivot_col_name , 
                    rank() over (order by @pivot_col_name ) AS RANK 
            from (
                  select distinct @pivot_col_name 
                  from `table_name`
                ) 
         ) a GROUP BY GroupbyCol 
  &quot;) header 
  USING pivot_col_name AS pivot_col_name
  
  END;
  </code></pre>
  <p>Calling SP as :</p>
  <pre><code>CALL `project.dataset.test_stored_procedure_ne`(
     'project.dataset.InputTbl'  #table_name
    , 'project.dataset.outputTbl'  #destination_table
    , 'Id' #row_id
    , 'PROPERTY_KEY' # column name
    , 'PROPERTY_VALUE' #column value
    , 'MAX' #aggregation if any
  );
  </code></pre>
  <p>Getting Error as :</p>
  <pre><code>Error validating procedure body (add OPTIONS(strict_mode=false) to suppress): Query error: Invalid value: Table name &quot;table_name&quot; missing dataset while no default dataset is set in the request.
  </code></pre>
  <p>Please explain how and when to put quotes which I believe am misplacing</p>