Change a dataset dynamically on BigQuery
Try the following:
CREATE OR REPLACE PROCEDURE project.independent_dataset.sp_test (dataset STRING)
BEGIN
EXECUTE IMMEDIATE
format("""
CREATE OR REPLACE TABLE `project.%s.d_test`
AS
SELECT 1 AS id, 'aaaa' AS name FROM `elzagales.%s.d_init`"""
, dataset, dataset);
END;
CALL project.independent_dataset.sp_test('dataset_y');
Using the above you do not have to create multiple procedures but can still achieve the desire results