Re: copy table structure

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 02/02/05


Date: Wed, 02 Feb 2005 22:09:32 +0100

On Wed, 2 Feb 2005 04:07:06 -0800, GW wrote:

>Appreciate it if someone can show me how to copy table structure to a new
>table without the data using a query.

Hi GW,

You could use

SELECT *
INTO NewTable
FROM OldTable
WHERE 1 = 0

This will copy the columns and datatypes; it won't copy defaults,
constraints, properties and such.

However, I'd be interested to know why you want to do this. What is the
goal?

Best, Hugo

-- 
(Remove _NO_ and _SPAM_ to get my e-mail address)


Relevant Pages

  • Re: Derived tables
    ... >the same query 2 times, ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.programming)
  • Re: Need a query
    ... >I need a query to get the following data set: ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.programming)
  • Re: Reuse Calculated fields in Select Queries
    ... >Say I have this example select query. ... I'd really hate to have to repeat my calculation each time I'd like to reuse it. ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.programming)
  • Re: Join Problems
    ... >The following query has failed to return all the records. ... >As per right outerjoin in the above statement I suppose to get all the ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.clients)
  • Re: calculate cummulative or store it
    ... >have a predefined query which does the cummulative. ... >takes time to do the calculation. ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.programming)