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

2
  • 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. Commented Jun 8, 2016 at 21:21
  • 2
    Possible duplicate of How to select from MySQL where Table name is Variable Commented Jun 8, 2016 at 21:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.