Link to home
Start Free TrialLog in
Avatar of kevinmackevin
kevinmackevin

asked on

How can i insert only disticnct values??

i am using a xml parser which runs every 20 mins and automatically inserts the data into the database.
It inserts the Stock's symbol, name, price and time (stock market time)

The problem is the parser runs all weekend long and just keeps putting in the same info, as the market is closed, at 4:00pm.


How  can make it so it will only insert it in if the time stamp is unique


Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of amitpagarwal
amitpagarwal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of flymo1234
flymo1234

A better solution would be to do :


declare @theUniqueThing int
select @theUniqueThing  = 0

select @theUniqueThing  =1
from   dbo.your_table yt
where  yt.stock_nm = @stock_nm
and    yt.time = @time
and    yt.price = @price


if (@theUniqueThing = 1)
BEGIN
   INSERT INTO dbo.your_table
        (a,b,c)
    VALUES
         (1,2,3)
END


Hope this makes sense.