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
 Express Edition and Compact Edition (2005)
 Insert Child Record

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-03-22 : 08:45:29
George writes "SQL server 2005 Express, Windows XP Pro SP2

I want to create a stored procedure that will insert a record in a child table (tblcontproj)propulating two columns with columns from the parent (InterestListoriginal)and two columns with user selected values. I created an insert select statement that looks like ..

" INSERT INTO tblcontproj(proj_rpt_id, proj_name) SELECT proj_rpt_id, project_name FROM InterestListoriginal WHERE (proj_rpt_id = @proj_rpt_id)"

This works great! Now can I add two columns to the INTO clause for projcontshortname and projconttye and use a VALUE clause that sets tblcontproj.projcontshortname and tblcontproj.projconttype to @projcontshortname and @projconttype which are user selected values from a downdownlist.

Or add an UPDATE query?

Thanks "

Kristen
Test

22859 Posts

Posted - 2006-03-22 : 14:45:25
"use a VALUE clause"

Nope, not quite!

INSERT INTO tblcontproj
(
proj_rpt_id, proj_name, projcontshortname, projconttye
)
SELECT proj_rpt_id, project_name, @projcontshortname, @projconttype
FROM InterestListoriginal
WHERE (proj_rpt_id = @proj_rpt_id)

Kristen
Go to Top of Page
   

- Advertisement -