Logo
4 Jun 2014 | 1 min. (84 words)

Copy table schema to new a table

In SQL Server, SELECT INTO is used to copy data from an existing table/s into a new one.

However by adding a WHERE clause which will always return false, this will prevent any data from being copied, and therefore create an empty copy of the table schema into a new table.

For example if we have a table, “TableA”, the schema of this table can be copied into a new table, “TableB”, by executing the following:

SELECT *
INTO TableB
FROM TableA
WHERE 1=0
schema select-into sql sql-server table
Twitter Facebook

Abstract config settings from web.config

…

Create a flashing tab notification page title

Learn how to create flashing page title, or use/fork the existing version…

Related Links

  • LinkedIn
  • Twitter: @curtcode
  • Stack Overflow
  • GitHub: @curtiscde

Stack Exchange

profile for Curtis on Stack Exchange, a network of free, community-driven Q&A sites
Follow @curtiscde

Recent Posts

  • Displaying latest posts on your GitHub profile
  • Using Codecov within a monorepo
  • Displaying Strava stats using webhooks & GitHub Actions
  • Filtering duplicate data points on Chart.js
  • Next.js Typerite Template Boilerplate
Theme Bleak by zutrinken Published with Hugo
Menu