Hi, this video is great, could you tell me how to set a variable from a select statement like in MS SQL like declare @i int select @i=max(id) from [dbo].[tbl] select @i Thanks
You need to use the IDENTIFIER function to dynamically construct the table name. Ex: SET DBNAME = 'DB1'; SET SCHEMA= 'SCH1'; SELECT * FROM IDENTIFIER($DBNAME || '.' || $SCHEMA|| '.TEMP');
Have you ever run into problems declaring variables. When I run a simple declare sSQL varchar(500) , I get syntax error at position..unexpected . I am trying to dynamically create a sql statement but I run in to string size limitation when I use your described technique. All attempts to declare the variable and assign datatypes are failing.
Thank you for the video. I am trying to set column names as I use to in oracle, using variables, but I cannot get it to work. For example, SET NAME1 = IMPORTANT_NAME Select Some_Name as $NAME1 from table1. Snowflake does not like this or using identifier($NAME1) etc. Any thoughts on this. I have a ton of column names that change every month that I wanted to preset as variables so that I don't have to keep changing the code. Thanks