3 added 127 characters in body
source | link

The identity property isn't transferred if the select statement contains a join, and so

select a.* into without_id from with_id a inner join with_id b on 1 = 00;

will also give the desired behaviour (of the copied id column to not keep the IDENTITY property.

Although However, as withit will have the side effect of not copying any row at all! (as with some other methods) so you'll then need to do:

insert into without_id select * from with_id;

(thanks AakashM!)

The identity property isn't transferred if the select statement contains a join, and so

select a.* into without_id from with_id a inner join with_id b on 1 = 0

will also give the desired behaviour.

Although, as with the other methods you'll then need to do

insert into without_id select * from with_id;

(thanks AakashM!)

The identity property isn't transferred if the select statement contains a join, and so

select a.* into without_id from with_id a inner join with_id b on 1 = 0;

will also give the desired behaviour (of the copied id column to not keep the IDENTITY property. However, it will have the side effect of not copying any row at all! (as with some other methods) so you'll then need to do:

insert into without_id select * from with_id;

(thanks AakashM!)

2 added 137 characters in body
source | link

The identity property isn't transferred if the select statement contains a join, and so

select a.* into without_id from with_id a inner join with_id b on 1 = 0

will also give the desired behaviour.

Although, as with the other methods you'll then need to do

insert into without_id select * from with_id;

(thanks AakashM!)

The identity property isn't transferred if the select statement contains a join, and so

select a.* into without_id from with_id a inner join with_id b on 1 = 0

will also give the desired behaviour.

The identity property isn't transferred if the select statement contains a join, and so

select a.* into without_id from with_id a inner join with_id b on 1 = 0

will also give the desired behaviour.

Although, as with the other methods you'll then need to do

insert into without_id select * from with_id;

(thanks AakashM!)

1
source | link

The identity property isn't transferred if the select statement contains a join, and so

select a.* into without_id from with_id a inner join with_id b on 1 = 0

will also give the desired behaviour.