Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql insert

Author  Topic 

asm
Posting Yak Master

140 Posts

Posted - 2006-02-27 : 04:18:22
Hi

I have table A : my char(6), ec (char6), j1 char(2), j2 char(2), j3 char(2), j4 char(2) ... upto j31

And have another table B : Mydate smalldatetime, Ec char(6), J char(2)

I want table A data should be inserted into table B

Table A Data : 022006 A1 B C D E
022006 A2 F G G I

Insert data in table B :
02/01/2006 A1 B
02/02/2006 A1 C
02/03/2006 A1 D
02/04/2006 A1 E
02/01/2006 A2 F
02/02/2006 A2 G
02/03/2006 A2 G
02/04/2006 A2 I


Pls guide how to write insert trigger for this or Store Procwedure


Thanks

ASM


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-27 : 04:26:28
[code]insert into tableB (Mydate, Ec, J)
select convert(datetime, right(my, 4) + left(my, 2) + '01'), ec, j1 from tableA union all
select convert(datetime, right(my, 4) + left(my, 2) + '02'), ec, j2 from tableA union all
select convert(datetime, right(my, 4) + left(my, 2) + '03'), ec, j3 from tableA union all
...[/code]

----------------------------------
'KH'


Go to Top of Page
   

- Advertisement -