Question

Locked

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

By ysgoh3 ·
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

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Annoyingly simple

by Tony Hopkinson In reply to Can we clone a table stru ...

select *
into #temptable
from Table


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

Collapse -

dang it..

by Shellbot In reply to Annoyingly simple

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

i've got to be a bit quicker!

Collapse -

It's the competitor in me

by Tony Hopkinson In reply to dang it..

I looked it up.

Collapse -

Really?

by pecusson In reply to Annoyingly simple

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

Collapse -

i want data dictionary for the e-commerce

by spatel_ce In reply to Can we clone a table stru ...

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

Collapse -

Just a single query can create a clone of ur table strut

by mahessabne2003 In reply to Can we clone a table stru ...

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

Back to Networks Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums