Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How can i insert only disticnct values??

Posted on 2003-03-29
Medium Priority
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
Question by:kevinmackevin

Accepted Solution

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

Expert Comment

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)
   INSERT INTO dbo.your_table

Hope this makes sense.


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

Ready to kick start your career in 2018? Add app developer skills to your resume. January’s Course of the Month features Android App Development training with hands-on learning.  Read on to learn why these skills are important.
The article explains the process to deploy a Self-Service password reset portal I developed a few years ago. Hopefully, it will prove useful to someone.  Any comments, bug reports etc. are welcome...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

571 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