?
Solved

How can i insert only disticnct values??

Posted on 2003-03-29
4
Medium Priority
?
250 Views
Last Modified: 2006-11-17
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
0
Comment
Question by:kevinmackevin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Accepted Solution

by:
amitpagarwal earned 300 total points
ID: 8233019
you can create an index on the table with the option of saying do not allow duplicates.

look at "create index " syntax
0
 

Expert Comment

by:flymo1234
ID: 8234379
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.

0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New style of hardware planning for Microsoft Exchange server.
IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question