Hi! I need to copy table with a lot of columns in SQL Database (mdf file), only structure without data and assign a new name to it. New table will have the same amount of columns only 2 of them will have different data types. Connected my database to SQL Server Management Tools but couldn't find an option of copying it. Please help.Â
How to copy tables in SQL Server
HELLO
Â
You can uses SELECT INTO statement for copy data from one table to another. And you can insert into the new table.
Â
Â
SELECT INTO STATEMENT
Â
SQL SELECT INTO Syntax
Â
Â
You can copy columns in the new tables.
Â
SELECT *
INTO newtable [IN externaldb]
FROM table1;
Â
If you want to data one table to another then use this code.
Â
SELECT empname.empnameName, Orders.OrderID
INTO empOrderBackup2013
FROM employee
LEFT JOIN Orders
ON employee.employeeID=Orders.employeeID;
Â
Â
Â
The select into statement used for following:- Â
1. Create new table
2. Empty tableÂ
3. If you want return with no data then add WHERE. ex:-
Â
SELECT *
INTO newtable
FROM table1
WHERE 1=0;
Â