12,996,367 members (62,954 online)
Rate this:
See more:
I want to insert new costcode values in to table only if the new value dose not exsist in costcode column already.
if it exsists so
the TranDate and amount will be updated for the exsisting cost code.

Simply:
if costCode exsist then update tranDate and amount else insert new row with new valuse for each column.

CostCode TranDate Amount
04 31/01/2013 12:00:00 AM 262033.83
07 31/01/2013 12:00:00 AM 31579.87
01 31/01/2013 12:00:00 AM 980834.24
09 31/01/2013 12:00:00 AM 197237.28

I need help urgently.

thanks
Posted 21-Feb-13 8:02am
joshrduncan2012 21-Feb-13 14:11pm

Saying it's urgent doesn't get guarantee you a quicker reply. What have you tried so far to accomplish this task?

Rate this:

## Solution 2

if(Exists(select 1 from tbl where costcode=yourcode))
begin

end

else

begin

insert sql

end
v2
Rate this:

## Solution 1

Query your table to see if your cost codes exists if it does then update the values that need to be updated, if it doesnt insert your new record.

SQL,

http://www.w3schools.com/sql/default.asp[^]

Top Experts
Last 24hrsThis month
 RickZeeland 235 ppolymorphe 180 OriginalGriff 115 Karthik Bangalore 90 Wonde Tadesse 90
 OriginalGriff 4,297 ppolymorphe 2,002 Kornfeld Eliyahu Peter 1,893 RickZeeland 1,751 Richard Deeming 1,493