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
 General SQL Server Forums
 New to SQL Server Programming
 INSERT Statement involving different tables

Author  Topic 

sadbjp
INNER JOIN

41 Posts

Posted - 2007-05-11 : 12:35:43
I have three tables:

1. RubricReport 2. RubricReportDetail and 3. RubricReportTemplate

RubricReportDetail has columns ReportID and Age
RubricReportTemplate has columns IndicatorID and Salary


I want to insert a row in RubricReport Table with ReportID = @ReportID (RubricReportDetail) and IndicatorID = @IndicatorID (of RubricReportTemplate). How can I do this?

Kindly help me with this. Thanks in advance.

sshelper
Posting Yak Master

216 Posts

Posted - 2007-05-11 : 12:40:14
Try this query:

INSERT INTO RubricReport ( ReportID, Age, IndicatorID, Salary )
SELECT A.ReportID, A.Age, B.IndicatorID, B.Salary
FROM RubricReportDetail A, RubricReportTemplate B
WHERE A.ReportID = @ReportID AND B.IndicatorID = @IndicatorID

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page
   

- Advertisement -