Compare Two Tables and insert Record Source Table With Increment ID

Increment ID using Row Number in Sql Server for Compare Two Tables

Source table has two Records ..and Destination table has 5 we get record from destination table ..but its not in source table ..that records inserted to source table.
now we dont using auto increment in source table,use this
Query for get the last ID of sourctable,then auomatically incremented the ID and get all except records from Destination table and
inserted Records to Souce table with incremented ID.

Source Table :categorymaster
Destination Table :categorymaster1

INSERT INTO categorymaster(CategoryCode,Description)

1 CategoryCode from CategoryMaster ORDER BY CategoryCode DESC )) + X.MaxID,
( SELECT Description from categorymaster1 where description not in
( SELECT description from categorymaster)) AS MyTable
CROSS JOIN ( SELECT MAX (CategoryCode) AS MaxID FROM CategoryMaster) X


Guest Author: Bharat20 Feb 2012

I have been garnisheeing on the best ways to invest our money but, I have not heard anything about a stock picks. Actually my friend told me about stock picks. I just want to know, is it a good way to invest our money in stock business?

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: