Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert into table without matching rows

Author  Topic 

adityaG
Starting Member

10 Posts

Posted - 2010-08-18 : 10:46:05
Hey folks ,

I am very new to the T sql environment so you might find this a very easy question.But still i need to correct my logic.Hence some help would be appreciated .
I am inserting data from one table to another with conditions like do not delete any data before inserting and do not insert if the record already exist . For insertion of records there is relation between two tables . ex .
Table A Table B
code, name,Rate ,startdate,enddate icode Name Rate


I want to insert data from tbl A to tbl B with code as the relation between them.

If there is some data in table B and it matches with code of table A then do not insert .

Which alternative will make sure that if the data already exist then do not insert else insert.

Can anybody help ?

X002548
Not Just a Number

15586 Posts

Posted - 2010-08-18 : 10:51:22
You need to provide sample data and expected reults..

But what I think you mean is

INSERT Data From Table A if there is No Key Data in Table B
UPDATE Data in Table B, if Key Data Matched between Table A & B

I would not worry if the columns are equal or not..but you could do that as well

Read this

http://weblogs.sqlteam.com/brettk/archive/2004/04/23/1281.aspx



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -