Migration from SQL Server to snowflake

Viewed 181

I need to convert the SQL Server stored procedure to snowflake - can you please help us?

CREATE PROCEDURE dbo.analyticsGetFilterNames 
    @product NVARCHAR(20) = '',
    @franchise NVARCHAR(20) = ''
AS
BEGIN
    SET NOCOUNT ON;

    IF @product = 'Menus' AND @franchise = 'Nissan'
    BEGIN
        SELECT * FROM table1
    END
    ELSE -- Triage & other brands
    BEGIN
        SELECT * FROM table2
    END
END
2 Answers

you need to make a Tabular SQL UDF(TSUDF) in snowflake :

CREATE OR REPLACE FUNCTION analyticsGetFilterNames ( 
  product NVARCHAR(20)
, franchise NVARCHAR(20)
)
RETURNS TABLE (<output_col_names>) AS 
$$
  IF product = 'Menus' and franchise = 'Nissan'
  BEGIN
     SELECT * from table1
  END
  ELSE -- Triage & other brands
  BEGIN
     SELECT * from table2
  END
$$
Related