473,785 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copying from one table to another

375 Contributor
Hi,

I have two tables emp and empcheck1 in the same database

emp consits 50 records
and empcheck1 consists of 25 records

Both the tables have the same design, here empid is the unique key

I want to insert all the datas from emp1 to empcheck1 in such a way that it should not rewrite or duplicate the original 25 records

Whatever 25 records are there in empcheck1 already exists in emp

So i want the rest of the 25 odd records to be copied to empcheck1 from emp


Can anyone let me know how to do that
i tried out
insert into empcheck1 select * from emp where emp.empid<>empc heck1.empid

But it gave me an error
May 20 '08 #1
1 1021
deepuv04
227 Recognized Expert New Member
Hi,

I have two tables emp and empcheck1 in the same database

emp consits 50 records
and empcheck1 consists of 25 records

Both the tables have the same design, here empid is the unique key

I want to insert all the datas from emp1 to empcheck1 in such a way that it should not rewrite or duplicate the original 25 records

Whatever 25 records are there in empcheck1 already exists in emp

So i want the rest of the 25 odd records to be copied to empcheck1 from emp


Can anyone let me know how to do that
i tried out
insert into empcheck1 select * from emp where emp.empid<>empc heck1.empid

But it gave me an error
hi

try the following query
Expand|Select|Wrap|Line Numbers
  1. insert into empcheck1(column1,column2,...)
  2.  select column1,column2,... from emp 
  3. where emp.empid not in (select empid from empcheck1)
  4.  
  5.  
thanks
May 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
32354
by: Caroline | last post by:
I need to update a table by copying a column from another table (having the same structure, but on another database), from the record having the same primary key. 1 - What is the correct query? 2 - I tried copying them record by record, but the datatype is ntext, (it displays <long
3
2572
by: sparks | last post by:
I was copying fields from one table to another. IF the var name starts with milk I change it to egg and create it in the destination table. It works fine but I want to copy the description as well. Short version :) For Each fld In tdf.Fields pos = InStr(fld.Name, "milk") If pos > 0 Then
5
3514
by: Lyn | last post by:
I am trying to copy selected fields from one table to another, by reading the source table record into a recordset (ADO) and then copying the relevant fields to an SQL statement "INSERT INTO...". The numeric and text fields copy without a problem, but it all falls in a heap when I try to copy a picture object field (data type OLE Object in both tables). I seem to be missing something ??? Reduced to its simplest form, this is the code...
2
9492
by: Erwin Van de Velde | last post by:
Hi, I have to copy data from one table to another, and I was wondering if there is an easier way to do that than to have a lot of inserts one after another. I already looked at the copy command, but what I need should happen in my program itself, while the user is waiting, and it's only a partial copy of the first table to the second (which has it's own fields, although with default values to start with). So the copy command didn't seem...
4
15423
by: zMisc | last post by:
Is it possible to copy a table from one schema to another schema by just copying the frm file to the directory for the new schema? What is the best way to create a new database with all the tables in it automatically? I was hoping to have the tables (the frm files) included in a subdirectory and when required, just create a new schema then copy all the frm files into it.
1
31171
by: Mike9900 | last post by:
What is the best way to copy DataRow from one table to another table, without copying its structure, which means copying only its data. -- Mike
8
3360
by: daD | last post by:
I'm trying to write a small database that tracks people coming and going from a small campground. I need to have the current guests in the "current" table" and then have the ability to check them out to the "archive" table when they leave, by pushing the "check-out" button. I see the steps as follows: 1. When the check-out button is pressed, the computer should automatically add the current date into the "date checked-out" field. ...
0
1566
by: berwiki | last post by:
I am trying to copy a table to another SQL 2000 Database, but I continually get errors. When I right-click, choose All-Tasks, Export-Data and go through the DTS settings, I get an 'Unspecified Error' on row 107 (which, looking at all visible data, there appears to be no difference than the 100 rows before it). Failed: Copying to a different database. Failed: Copying to the Same database with a different table name.
5
17520
by: ozzii | last post by:
Hi I am using the following code to copy data from one database table into another database table: SELECT * INTO Products From exportdb.mdb.exporttable However the query simply deletes everything in the Products table before copying the content of the exporttable. what is the syntax to run a similar query so that data is simply appended to the products table instead of deleting the entire contents before copying the exporttable?
5
1897
by: mark_aok | last post by:
Hi all, I have a situation where I have a split database. At the back end, I need to - create a new table (I will call it newTable) with the exact fields, and relationships as another table (let's call it oldTable, and I need to copy everything EXCEPT the data). - Then I need to delete oldTable, and rename newTable 'oldTable'
0
9491
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.