Home > Enterprise >  Create table and insert values from different datatypes
Create table and insert values from different datatypes

Time:12-11

Code:

create table "tab1" ("c1" varchar(max));
create table "tab2" ("c3" integer);
insert into tab1 values(N'asd'), (N'qweqwe');
insert into tab2 values(123), (345);
select
c_newname as myname
from
(
select "c1" as c_newname from "tab1"
union all
select cast("c3"  as varchar(max)) from "tab2"
) as T_UNI;

How to create new table("tab3") and insert values from(tab1),(tab2) into table("tab3"). Thank you...

CodePudding user response:

It looks like you're using SQL Server, so you can use into

select c_newname as myname
into tab3
from...
  •  Tags:  
  • sql
  • Related