Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6742057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:47:53+00:00 2026-05-26T11:47:53+00:00

Afternoon All, I have a button on a web page that when is clicked

  • 0

Afternoon All,

I have a button on a web page that when is clicked by the user inserts data into a table. this button has a message box assigned to it, to let the user know the records have been saved and then redirects the user to the home page. This in its current state works perfectly fine.

My problem is that I wish to find a solution to stop the user going back to the page where this button is located and inserting the data again. I need to get round having duplicate records in the database table.

I’m presuming that from what I have read on the internet that I should be using the ‘IF EXISTS’ function within my stored procedure. I’m not 100% sure how this will work with the current code that I have in my Stored Procedure? I’m only want to check that these records are available and if not then to add add them or if they already exist then not to add these.

I just think that I have confused myself slightly with the amount of articles etc that I have read on the internet.

Here is my current stored procedure:

ALTER PROCEDURE [dbo].[GasNominationsRawData_Insert]

AS SET NOCOUNT ON;  

INSERT INTO dbo.GasRawData (timestamp,TagName,Value) 

    SELECT timestamp AS Interval, Left(Right(TagName,Len(TagName)-5),Len(TagName)-10) As TagName,
    CONVERT(decimal(10, 2), ROUND(value, 2)) As Value
    FROM 
       OPENQUERY(IHISTORIAN,'
        SET starttime =''yesterday +4h'', endtime =''today +6h'' 
        SELECT timestamp, tagname, value
        FROM ihRawData
        WHERE tagname = "UMIS.99FC9051.F_CV"
           OR tagname = "UMIS.99F851C.F_CV"
           OR tagname = "UMIS.35GTGAS.F_CV"
           OR tagname = "UMIS.99XXG546.F_CV"
        AND timestamp BETWEEN ''timestamp'' and ''timestamp'' 
        AND SamplingMode =Calculated
        AND CalculationMode =Average
        AND IntervalMilliseconds =1h
        ORDER BY tagname, timestamp
        ')

Any help or suggestions would be much appreciated.

Regards Betty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:47:53+00:00Added an answer on May 26, 2026 at 11:47 am

    One very simple way of preventing duplicates is to add a UNIQUE INDEX on the field(s) you want to keep distinctive.

    CREATE UNIQUE INDEX ix_MyIndexName ON Table(Field1, Field2, Field3)

    This will throw an error if you try to insert a duplicate value for the fields listed.

    Alternatively, you can add the option IGNORE_DUP_KEY = ON to the above to continue if a duplicate value is attempted to be inserted. A warning will be generated but it won’t cause the query to fail.

    This has minimal overhead and won’t require you to do any maintenance work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good afternoon all. I have a page that displays data in a gridview based
I have had that weird error this afternoon... I cannot figure out why System.Data
Afternoon All I have some data - var searchwithin = [ {id:clearwithin, type:button}, {id:search_radius,
Good Afternoon All, I have a table inside a div. The div has a
Afternoon all. I have the following scenario: I have a search page where by
Good afternoon all, I have a class which looks like this: public class Grapheme
Good Afternoon All, I have a wizard control that contains 20 textboxes for part
Good afternoon to all, I have this scenario: I am using SQL Server 'BulkInsert'
Good Afternoon All, I have written an SSIS 2005 package that contains a conditional
I have been trying all afternoon to try and achieve this with no success.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.