473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

copying from one table to another

375 256MB
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<>empcheck1.empid

But it gave me an error
May 20 '08 #1
1 1007
deepuv04
227 Expert 100+
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<>empcheck1.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
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...
3
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...
5
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...". ...
2
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,...
4
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...
1
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
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...
0
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...
5
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...
5
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.