Question Locked

Can we clone a table structure to temp table in SQL server

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Can we clone a table structure to temp-table in SQL server stored procedure?

If yes, how should we declare the temp table and the command the clone the table structure?

or can provide us a sample codes on the above solution.

Thanks

7 replies

by tony hopkinson

select *
into #temptable
from Table

if you only want the structure
Select Top 0 * ...

by shellbot

i rejoiced that there was a question i could answer..and you beat me to it :)

i've got to be a bit quicker!

by pecusson

What about the constraints? Is there a way to clone them automatically?

by spatel_ce

And related table information means how many table and which r they and what is the field inf each table.

by mahessabne2003

just execute the below query to create a clone of the table u want to create,if u want a black table type the where condition else remove the where clause.

select * into Temp_tablename from tablename
where 1=2

This discussion is closed to new replies.