473,547 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Merge command

debasisdas
8,127 Recognized Expert Expert
Using Merge command (supported version 9 onwards)
=============== =============== ==========
Used to go for insert/update in a single command based on some condition.

Example #1

Expand|Select|Wrap|Line Numbers
  1. merge into emp5 e
  2. using (select empno,ename from emp) e1
  3. on (e.empno=e1.empno)
  4. when matched then
  5. update set
  6. e.ename=e1.ename
  7.  when not matched then
  8. insert values(e1.empno,e1.ename)
  9.  
If the empno exists then update else insert the record.

Example#2

Expand|Select|Wrap|Line Numbers
  1.  
  2. merge into empls e
  3. using emp e1
  4. on (e.empno=e1.empno)
  5. when matched then
  6. update set
  7. e.ename=e1.ename,
  8. e.job=e1.job,
  9. e.mgr=e1.mgr,
  10. e.hiredate=e1.hiredate,
  11. e.sal=e1.sal,
  12. e.comm=e1.comm,
  13. e.deptno=e1.deptno
  14. when not matched then
  15. insert values(e1.empno,e1.ename,e1.job,e1.mgr,e1.hiredate,e1.sal,e1.comm,e1.deptno)
  16.  

Just another simple example .
May 9 '07 #1
0 3119

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

Similar topics

1
2404
by: Aaron | last post by:
Hi People, Does anyone know how to start a mail merge with ms access to ms word? At the moment i select the records i wish to merge with a query, get the results, then select Office Links from the menu that goes through a wizard to acomplish the merge. I would like to create a Command button on a form that upon clicking will simply...
4
6272
by: Dadio | last post by:
Hello On my Access database form I have a command button which opens a Word mail merge document in which I have created a number of fields (Title, FirstName, LastName, Address1 etc.) I would like to be able to populate the Word document with the contents of the currently selected Access record so that when I press the button in Access,...
3
5570
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge document in Word; 2. opens the document and runs the merge process for the new data. I have managed to write the code to perform step 1 ok, but I'm...
9
5599
by: rkk | last post by:
Hi, I have written a generic mergesort program which is as below: --------------------------------------------------------- mergesort.h ----------------------- void MergeSort(void *array,int p,int r,int elemSize,int(*Compare)(const void *keyA,const void *keyB));
3
2601
by: John Cosmas | last post by:
I have a DATATABLE which I have populated in my application, and I need it written out to a particular table I specify in my ACCESS database. My code works to the point of the MERGE and UPDATE, but it creates exactly the number of BLANK records per the populated DATATABLE. Here is my code... pstrDestinationTable = "tws_tbl_Case_Scanner_" &...
8
13324
by: Ron B | last post by:
Help!!! What am I doing wrong? I am working with Office 2003 and am trying to create a command button on an Access form that will create a mail merge in Word from an Access table. I want to make the mail merge seamless to the user so all they have to do is click on the command button and the letters are generated. For the button I...
2
1291
by: Benny Ng | last post by:
Dear All, Now i have a two dataset. they have same db structure and same columns and same rows. just the content is not same between them. for example: datagrid 1:
3
5479
by: ljungers | last post by:
I need to make some changes to a Query/select/print report using word application. What I need to do is change the way Word is called yet keep the process the same. Word is used so changes can be made before actual printing. Need some way of calling Word as a mail merge with the information from an Access table that the current report uses. I...
1
11454
by: kirkus84 | last post by:
I am currently trying to do a multiple record mail merge through a query via a command button on a form. The query basically displays customers who have said yes to privacy. The user inputs a date into txtDate on frmDate and the clicks "View Queried Privacy Records" Once they click this it opens the query form frmPrivacy which then has a command...
0
7437
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...
0
7703
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. ...
0
7947
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...
1
7463
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...
0
6032
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...
0
5081
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...
0
3493
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...
1
1923
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
748
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...

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.