如何将记录从具有不同结构的一个表复制到另一个表

问题描述:

hii

我有两个表emp(3列)和empwithcontact(4列).我想将所有记录从emp复制到empwithcontact,并在最后一列中默认插入"0000".我已经尝试过...但是发生了错误(语法错误,接近0000)...

hii

i have two tables emp( 3 colums) and empwithcontact (4 columns). i want to copy all records from emp to empwithcontact and in the last column i want to insert "0000" by default. i''ve tried this... but error occoured (incorrect syntax near 0000)...

 INSERT INTO [onlineexam].[dbo].[empwithcontact]
           ([id]
           ,[name]
           ,[address]

SELECT  [id]
       ,[name]
       ,[address]
FROM [onlineexam].[dbo].[emp] ,'0000' 

INSERT INTO [onlineexam].[dbo].[empwithcontact]
([id]
,[名称]
,[地址],[4thcolumnname]

SELECT [id]
,[名称]
,[地址],''0000''
FROM [onlineexam].[dbo].[emp]
INSERT INTO [onlineexam].[dbo].[empwithcontact]
([id]
,[name]
,[address],[4thcolumnname]

SELECT [id]
,[name]
,[address],''0000''
FROM [onlineexam].[dbo].[emp]


尝试一下.
Try this.
INSERT INTO [onlineexam].[dbo].[empwithcontact]
           ([id]
           ,[name]
           ,[address],
           ,[4th_column_name])
 
SELECT  [id]
       ,[name]
       ,[address]
       ,'0000'
FROM [onlineexam].[dbo].[emp]