Re: backup table to another table in database



On Tue, 17 Jan 2006 08:04:03 -0800, Danne wrote:

>I need to create a new table with the same columns using a select from
>another table. I cannot find the syntax. Does anyone know if this can be
>done in SQL 2k?

Hi Danne,

To copy the columns and the data at the same time (but not the
constraints, poroperties or indexes!!), use

SELECT Column1, Column2, ...
INTO NewTableName
FROM OldTableName
WHERE ....

--
Hugo Kornelis, SQL Server MVP
.



Relevant Pages

  • Re: Outer Join Compatability in SQL Server 2000
    ... SQL Server MVP ... > syntax actually works. ... > Query contains an outer-join request that is not permitted. ... > FROM student stu LEFT JOIN student_product sp ON (stu.student_id = ...
    (microsoft.public.sqlserver.programming)
  • Re: COUNT function not working with GROUP BY
    ... us more info, and maybe even some sample data and sample output, or at least ... SQL Server MVP ... > FROM Base_Contacts LEFT OUTER JOIN ... > syntax must be wrong because the ...
    (microsoft.public.sqlserver.server)
  • Re: large varchar columns in SQL server
    ... of rssyntax without saving to a variable first. ... Aaron Bertrand [SQL Server MVP] wrote: ...
    (microsoft.public.inetserver.asp.db)
  • Re: NULL Records
    ... That was the code I was writing, but it kept giving me an error say syntax ... "Jacco Schalkwijk" wrote: ... > SQL Server MVP ...
    (microsoft.public.sqlserver.server)
  • Re: Table parameters
    ... >> procedure parameters. ... >> SQL Server MVP ... >>> I'm currently searching the ability to create a stored procedure with ... >>> I'm having trouble with finding the right syntax. ...
    (microsoft.public.sqlserver.programming)