hocuspocus31
hocuspocus31

Reputation: 183

copy table data to a different database using stored procedure

Just wondering, im new to stored procedures,

I just tried this

INSERT INTO new.emp SELECT * FROM old.users

and it worked and inserted the data of users from the old table users to the new emp table.

But when I did that inside a stored procedure im getting a syntax error

CREATE PROCEDURE insertnew
    INSERT INTO new.emp SELECT * FROM old.users

What's the difference?

Upvotes: 0

Views: 1385

Answers (1)

Chisskarzz
Chisskarzz

Reputation: 171

In what part of the query are you getting a syntax error? The correct syntax for creating a stored procedure is something like this:

DELIMITER //
CREATE PROCEDURE InsertEmployee()
BEGIN
    INSERT INTO new.emp SELECT * FROM old.users;
END //
DELIMITER ;

Upvotes: 1

Related Questions