Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert InTo Problem

Status
Not open for further replies.

EstuardoSierra

Programmer
Sep 23, 2003
38
PT
Hello All:

Since a couple of hours ago i'm trying to Insert some rows in to another table. My problem is that i can't figure out how to insert values from a recordset (Select) and at the same time insert other values from passed parameters.
This is the common way usign a recordset
Insert into tblname (fld1,fld2,fld3..)
Select fld1a, fld1b, fld1c..
From tblname2

This is the common way with values
Insert into tblname (fld1,fld2,fld3..)
Values ('fld1a', 'fld1b', 'fld1c'..)

But what i want to do is the best of both worlds
@value4 nvarchar(16)
AS
Insert into tblname
Values (Select fld1a, fld1b, fld1c, @value4)
From tblname2

I know my aproach is a mess but i really ran out ideas
can someone help me to achive the same result please?

Thanks in advance

Estuardo




 
sorry, do you get an error? if so, what is the description of error?

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Code:
Insert into tblname (fld1,fld2,fld3,field4)
Select fld1a, fld1b, fld1c, @value4
From tblname2
 
Try this:

Insert into tblname
(Select fld1a, fld1b, fld1c, :mad:value4)
From tblname2

valu4 may be taken as bind variable that is passed, and is constant for a transaction.
 
Thanks to All!!

First of all my apoligizes for not being able to reply on time.
Second, i appreciate the help supplied.
IonFilipski:
Following your question. No. It does not complains. it just "skip" that line. (weird!).
I end up, applying swampBoogie's suggestion, and it works as expected... smoooooth. Thanks a lot :)
Rachoor:
Thank you for the new (for me) sintax i'll give it a try.

Once again, deeply thank you.

Regards

Estuardo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top