How to use identifier() as reference

standup1
Contributor

Hello,

i am trying to build some dynamic sql scripts using this identifier() clause. This works fine when it is used with [ select * from identifier (mytable) ]. However, when I try to use this identifier as a reference to a foreign key table, it doesn’t work. For example,

CONSTRAINT s_t_fk FOREIGN KEY(fk1) REFERENCES identifier(mytable).

 Any idea how to use an identifier() or a variable when referencing to table? I am using sql warehouse. Not spark sql. Thank you