[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

sql insert question

Posted on 2001-06-08
8
Medium Priority
?
208 Views
Last Modified: 2010-04-06
I need to insert some table (padronf) with all it's records and fields into another table (padron) which has the same records (I mean the same names) plus one which is autonumber. So to be short, I need the SQL statement to insert all the records in padronf into padron and generate the correct autonumbers for IdAfi.
I know this is done with the INSERT keyword but don't know the correct sintax.

So, do you know how to do this? I suppose you do, so please help me.

thanks.
0
Comment
Question by:pin_plunder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 8

Expert Comment

by:Cesario
ID: 6168426
Hi,


try this statments ;-)

MERGE SELECT * FROM padron
  WITH SELECT * FROM padronf

Regrads

Cesario
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6168539
Insert into padron (FieldList_AutoincField_Excluded) Select (FieldList_AutoincField_Excluded) from padronf
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6168557
sorry, should be

Insert into padron (FieldList_AutoincField_Excluded) Select FieldList_AutoincField_Excluded from padronf

;-)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:pin_plunder
ID: 6171095
Cesario: I get the error 'Invalid use of the given token: MERGE'.

kretch..: there are 20 fields, I won't write all there names twice. And, I must say I tried to do so, but not  autonumber is 'created'.

thanks.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6171265
>but not  autonumber is 'created'.

is this number for the autonumberfield not provided by your databasesystem?
what databasesystem do you use?
0
 

Author Comment

by:pin_plunder
ID: 6171775
sorry, just corrected that. However, my question now is the following: is there any way to avoid duplicate records. Supose I run the sql command with the insert statement. Now I do this again. So, those records will be twice in padron.db.

can I avoid this?

thanks.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6172885
well

insert into padron select * from padronf where autonumberfield not in (select autonumberfield from padron)
0
 
LVL 2

Accepted Solution

by:
Felixin earned 150 total points
ID: 6248966
Did you try

Insert into padron (FieldList_AutoincField_Excluded) Select DISTINCT FieldList_AutoincField_Excluded from padronf

?

Felixin

Pimientos del Padron : unos pican y otros no
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question