0

I have a SQL Server table with several columns, an index starting from 1 as primary key.

Now I need to clone this table but without the data and with a different index, let's say starting from 100 000. I have never done this before so I am quite unsure about how to do it. I know how to create a new table,

CREATE TABLE new_table
AS (SELECT * FROM old_table);

but I do not know how to start the index from 100 000 and clone it without the data from the original table keeping the structure and the datatype exactly the same. Some help will be appreciated.

I am using SQL Server 2012 Express that came with Visual Studio 2012.

1
  • Which database are you using ? Commented Sep 11, 2013 at 11:35

3 Answers 3

1

SQL Server does not support CREATE TABLE AS SELECT.

Use this

SELECT  *
INTO    new_table
FROM    old_table

or

SELECT TOP 0 * INTO new_table FROM old_table
Sign up to request clarification or add additional context in comments.

Comments

1

Try this

CREATE TABLE new_table AS SELECT TOP 0 * FROM old_table 

1 Comment

try this SELECT TOP 0 * INTO newTable FROM OldTable
1

try this SELECT TOP 0 * INTO newTable FROM OldTable

1 Comment

You should give only one answer and/or eventually update your own one not post double. However thanks but the first one did not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.