1

I'm inserting data into Snowflake table via stored proc. I have a column in table where i want to capture the query id when the insert statement will run. Any suggestions how this can be achieved?

Cheers,

Kshitij
  • 47
  • 6

1 Answers1

1

Sorry, but not likely - last query id is only granted when the query is sent for execution, so you can't get it for "this" query. you can try to do this retrospectively (so first insert and then update), but i'm afraid that in turn won't be too concurrent

question is however - what exactly are you trying to achieve, maybe there is an easier way?

MMV
  • 920
  • 4
  • 9
  • I've seen this type of request before and the best use-case for this is that often users want to stamp which query either inserted or updated a record during their ETL process. Having to do a 2nd pass on that information to update the query_id is over-processing and difficult. Ideally, I'd like to see a `last_query_id(0)` return the current query_id in your statement. That'd be nice! – Mike Walton Apr 03 '20 at 15:01
  • Hi. I'm basically trying to achieve what Mike said in his above post. i want to capture which query either inserted or updated a record during the ETL process. Looks like at the moment the only way is to do an update statement. – Kshitij Apr 06 '20 at 01:23