0

I am getting error when I do following, I need your help to resolve this error or better way to handle. Any help is greatly appreciated.

SET @SourceDatabase := 'XYZ';

SET @DestinationDatabase := 'ABC';

INSERT INTO @DestinationDatabase + '.' + `Table1`

Error:-
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@DestinationDatabase + '.' + ABC at line 1 0.000 sec

lmo
  • 37,904
  • 9
  • 56
  • 69
user5889117
  • 107
  • 1
  • 8
  • unless using dynamic SQL, tablename and field name can't be dynamic. you could combine your insert statement into a string variable and then execute the variable. – xQbert Jun 08 '16 at 21:21
  • 2
    Possible duplicate of [How to select from MySQL where Table name is Variable](http://stackoverflow.com/questions/8809943/how-to-select-from-mysql-where-table-name-is-variable) – Willem D'Haeseleer Jun 08 '16 at 21:21

0 Answers0