Hi I want to populate value for Auto increament column when insert value for a table from another table. below is query im using and it throws error
create table test12
(
Id int,
name varchar(255),
dept varchar(255)
)
insert into test12 values(1,'f','cs'),(2,'b','cse'),(3,'c','cs'),(4,'d','cse'),(5,'e','cs'),(6,'f',null)
select * from test12
create table test34
(
seq int identity(1,1) not null,
name varchar(255) not null,
dept varchar(255) default('cs')
)
insert into test34(seq,name,dept) values
(1,(select name from test12),
(select case when dept='cse' then 'Y' else 'N' end as dept from test12))
Please let me what is the mistake
Aucun commentaire:
Enregistrer un commentaire