I am learning how to use SQL and Stored Procedures. I know the syntax is incorrect:
Copy data from one table into another table on another Database with a Stored Procedure. The problem is I don't know what table or what database to copy to. I want it to use parameters and not specify the columns specifically.
I have 2 Databases (Master_db and Master_copy) and the same table structure on each DB.
I want to quickly select a table in Master_db and copy that table's data into Master_copy table with same name. I have come up with something like this:
USE Master_DB
CREATE PROCEDURE TransferData
DEFINE @tableFrom, @tableTo, @databaseTo;
INSERT INTO @databaseTo.dbo.@databaseTo
SELECT * FROM Master_DB.dbo.@tableFrom
GO;