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 |
|
tommy222
Starting Member
2 Posts |
Posted - 2009-02-24 : 07:35:58
|
| Hi,I have two main DB tables that look like this;Table: RequestsReq_ID Surname Forename Age Manager_Name Graduate1 Smith John 25 Tom Jones Yes2 Example Andrew 31 Angie Holmes NoTable: Checklist ActionsChk_Action Initial_Status StatusSend Offer No ActiveEmployee Talk No ActiveWelcome Letter No ActiveI would like to know how to create the following statement/logic….WHEN a new record is added to Table: Requests.THEN use this data to CREATE table entry into Table: Request Progress containing Req_ID, Forename, Surname AND each of the Chk_Actions from Table: Checklist Actions with a value of No for each action….So the table would look something like this…..Table: Request ProgressRequest Surname Forename Send_Offer Employee_Talk Welcome_Letter1 Smith John No No No2 Example Andrew No No NoCould anyone tell me how to do this?Many ThanksTom |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-24 : 08:51:26
|
| Have you tried with Trigger? |
 |
|
|
tommy222
Starting Member
2 Posts |
Posted - 2009-02-24 : 08:56:53
|
| Thanks for the reply an no i haven't tried this could you tell me how? |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-24 : 09:14:11
|
| [code]try this by sample procedurecreate proc usp_sampproc(@id int)ASSET NOCOUNT ONBEGIN insert into RequestProgress (Request, Surname, Forename, Send_Offer, Employee_Talk, Welcome_Letter) select Request ,Surname, Forename, (select Initial_Status from cChecklistActions where Chk_Action = 'Send_Offer') , (select Initial_Status from cChecklistActions where Chk_Action = 'Employee_Talk'), (select Initial_Status from cChecklistActions where Chk_Action = 'Welcome_Letter') FROM Requests WHERE req_id = @idENDSET NOCOUNT OFF[/code] |
 |
|
|
|
|
|
|
|