Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to move the records from one table to another but number of column is different using sql server

$
0
0


Hi,
this below query is create the table. i want move the records for this table from another table.

declare @columns nvarchar(max)
set @columns='['+'ID'+'] Mem_ID,'+  '['+'RefID'+'] int,'
select @columns =  @columns+
                  '['+COALESCE( replace(cond,'_sys_defined',''),' ,')+'] datetime,'
                  from Condition
where idt=23
select @columns='create table idt_23('+SUBSTRING(@columns, 1, LEN(@columns) - 1)+')'
exec sp_executeSql @columns

i have another one  table is there. table name is test

select * from test id=23 . this reslt is moved to the idt_23 table.

but number of column is different source and destination table.
source is 300 columns, destination is my be 50 columns.

Regards,
Abdul Khadir.M


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>