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)
 Insert Help!

Author  Topic 

amodi
Yak Posting Veteran

83 Posts

Posted - 2009-06-09 : 02:03:45
Hello friends,
I have four tables EmployeeTable, DepartmentTable, MessageTable and EmployeeMessageTable.

EmployeeTable:
EmployeeId
FK_DepartmentId --Relationship with PK_DepartmentId column of DepartmentTable.

DepartmentTable:
PK_DepartmentId
DepartmentName

MessageTable:
PK_MessageId
Message

EmployeeMessageTable:
EmployeeId
Fk_MessageId – Relationship with PK_MessageId column of MessageTable.

I want to write a insert query that will take DepartmentId say “1” and MessageId say “35” as input. If department “1” contains 10 employees then query should insert 10 records in “EmployeeMessageTable” as:

Insert into EmployeeMessageTable(EmployeeId,fk_MessageId) values(“Emp_1_department_1”,35)
Insert into EmployeeMessageTable(EmployeeId,fk_MessageId) values(“Emp_2_department_1”,35)


Insert into EmployeeMessageTable(EmployeeId,fk_MessageId) values(“Emp_10_department_1”,35)

Query or stored procedure example would be helpful.

Thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-09 : 02:07:44
dup. see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=127284


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

amodi
Yak Posting Veteran

83 Posts

Posted - 2009-06-09 : 02:27:46
quote:
Originally posted by khtan

dup. see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=127284


KH
[spoiler]Time is always against us[/spoiler]





Thanks KH. Excuse me for posting the above topic in many sections of this forum.
Go to Top of Page
   

- Advertisement -