Stored Procedure

Insert data from other table

Page 1 of 1

1 Replies - 746 Views - Last Post: 25 August 2009 - 07:07 AM Rate Topic: -----

#1 chandak4u  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-August 09

Stored Procedure

Posted 25 August 2009 - 01:12 AM

Hello to all.....i need some help ..
I want to insert data in a table from other table by using join ....The data should be depend on the month of passing date...

Table1: Master table

column's :
eid name working_status
1 aaaa Y
2 xxxx y
3 kkkk y
and so no...

Second Table : Daily_attendance

columns :
eid Date Present
1 1/08/09 P
2 1/08/09 p
3 1/08/09 A
................
................
1 2/08/09 P
2 2/08/09 p
3 2/08/09 A
................
................
1 3/08/09 P
2 3/08/09 p
3 3/08/09 A
................
................

and than i have a table...... Monthly_attend_table

whenever i pass any date of aug or any month in a query . example : '01/08/09' or '23/08/09' . Its generate the attendance sheet of august month
the result insert in this format by using of master and daily_attendance table

columns :

eid name date 1 2 3 4 ..........31

1 aaaa 12/08/09 p p p
2 xxxx 12/08/09 p p p
3 kkkk 12/08/09 A A A




Plz help....


Thanks a lot....

This post has been edited by chandak4u: 25 August 2009 - 01:35 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Stored Procedure

#2 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 260
  • View blog
  • Posts: 1,417
  • Joined: 07-April 08

Re: Stored Procedure

Posted 25 August 2009 - 07:07 AM

your going to want to use an inner join.


Your join will look similar to the following:


INSERT INTO Monthly_attend_table
SELECT [all your columns to be selected]
FROM table 1 t1
		  inner join table 2 t2
			   on t1.eid = t2.eid 
			   AND t2.Date BETWEEN @StartDate AND @EndDate



This post has been edited by rgfirefly24: 25 August 2009 - 07:10 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1