Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clone table schema 1

Status
Not open for further replies.

lachie

Programmer
Joined
Jun 12, 2001
Messages
25
Location
AU
Does anybody know of an easy way to clone a table's schema into a new table. Keeping default values, identities intact.

Thanks,

Lachlan
 

In the database window, right-click the source table. Select copy. Right-click the database window and select paste. Type a table name and select "Structure Only." Click OK and you have a new table with all the attributes of the old table. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it if you have time.
 
Sorry, I was a little rushed when doing this... What I meant was..

I need a way to clone a table's schema programatically, either through a system stored procedure or some other means.


I have looked through the archives and have been unable to find a suitable way of doing so. I have also looked through the SQL books online to find an easy way of doing this and drawn blanks.

If any one can help, that would be great.
 

And I was rushed too and slightly confused. I can see that I gave an Access answer in a SQL forum. I apologize for that.

I know there is some info available explaining how to do what you want. I can't remember where to find it right now. If you don't already have an answer I'll try to find after I get to work - in about 8 hours. Need some sleep now. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
SQL_DMO allows you to transfer objects, copy schemas, etc. SQL Server hooks into SQL-DMO using the SP_OA stored procedures. The following link explains how to use the SP_OA procedures and has several examples including "Transfer a Single Table Structure and Data."

INF: Examples of Sp_OA Procedure Use and SQ[tt]L[/tt]OLE.Transfer[/ignore] Object
Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Thanks heaps big T!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top