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.
| Author |
Topic |
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2004-06-17 : 01:05:48
|
| Emp_Details: ref_id emp_id Class1 Class2 Address756 23456 Level1 Stage1 erteryey456 65789 Level1 fghghjgj789 76542 Stage6 tyutyutu tracking_Details:Inc_id emp_id ref_id Dept Start_date1 23456 756 PT 12/6/042 65789 456 SC 23/6/043 76542 789 PT 11/5/04 I have 2 tables one table is the emp_details table and the other is the tracking table.Now emp_details table has the data inside.I have to transfer certain details to the tracking_details.These are the constraints1. corressponding emp_id and ref_id should be transfered2. the record is pulled is like if there is data in Class1 and Class2 OR if there is only data in class2 then "Dept" in tracking_details should be "PT".3. If there is data only in Class1 then "Dept" in tracking_details should be "SC"4. Start_date is the todays dateplease show me how to tackle this problem using T-SQl |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2004-06-17 : 01:23:29
|
| INSERT INTO tracking_Details (emp_id, ref_id, Dept, Start_date)SELECT emp_id, ref_id, CASE WHEN (Class1 IS NOT NULL AND Class2 IS NOT NULL) THEN 'PT' WHEN (Class1 IS NULL AND Class2 IS NOT NULL) THEN 'PT' WHEN (Class1 IS NOT NULL AND Class2 IS NULL) THEN 'SC' end, GetDate()from emp_detailsThis is assuming that the Inc_ID is an IDENTITYFor DTS, you can simply use the SELECT statement as the source of the Transform data task. Though, why you would want to do this in DTS is beyond me. |
 |
|
|
|
|
|