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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Inserting form one table to other

Author  Topic 

coagulance
Yak Posting Veteran

78 Posts

Posted - 2009-06-04 : 08:38:08
Hi,

I have a Master table with the below fields:
JobType SeqNo Details
AAA 1 Europe
AAA 2 Asia
AAA 3 S.A
AAC 1 nzl
AAC 2 Oz


I need to insert all records of the Master Table in to a Running Table with only the Job Number changed like below:

JobType SeqNo Details
AAA0901 1 Europe
AAA0901 2 Asia
AAA0901 3 S.A

(I have written the function to create the JobType from Job Number)

Any suggestions other than using Cursors ?

Thanks,






SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-04 : 08:42:57
INSERT RunningTable (JobType, SeqNo, Details)
SELECT JobType + '0901' AS JobType, SeqNo, Details
FROM MasterTable



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-06-04 : 08:44:48

You dont need a seperate table
Just use select query

select jobtype + '0901' as jobtype, seqno, details from your_table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-06-04 : 08:45:45


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

coagulance
Yak Posting Veteran

78 Posts

Posted - 2009-06-04 : 09:30:44
Thanks Peso!
Go to Top of Page
   

- Advertisement -