How to concatenate variables into SQL strings

后端 未结 2 1295
Happy的楠姐
Happy的楠姐 2021-02-08 11:51

I need to concatenate a variable table name into my SQL query such as the following...

ALTER FUNCTION fn_myfunction(@KeyValue text)
BEGIN
     INSERT INTO @tmpTb         


        
2条回答
  •  不要未来只要你来
    2021-02-08 12:14

    You could make use of Prepared Stements like this.

    set @query = concat( "select name from " );
    set @query = concat( "table_name"," [where condition] " );
    
    prepare stmt from @like_q;
    execute stmt;
    

提交回复
热议问题