Like somuch.com on Facebook Share somuch.com on Facebook somuch.com on Twitter Reddit LinkedIn Pinterest
Newest Tips & Tricks...

Home :: Tips & Tricks :: Microsoft SQL Server

Quickly Duplicate Table Structure

Here is a quick way to create a table that has the same structure as an existing table (without listing the entire CREATE TABLE syntax of the other table).

Just run the query...

SELECT * INTO [new table] FROM [old table] WHERE (1 = 0)

You can even use it in a stored stored procedure to create a temp table

select * into #temp from [my table] where 1 = 0

Source: Terri Morton, [aspsqlserver2000]

Recommended Links...