1

Two servers. Server A and Server B both has database named KPS. KPS has two tables complaint and attachment. KPS database on server A gets the value from the Web.

Both table if the submitted value = 1 then run the insert query which will insert the col1,col2 and col3 from Server A KPS to Server B KPS. They both are linked server. Both table attachment and complaint submit value needs to be 1 if it is 0 then do not insert. There will be two insert query one for complaint and one for attachment.

Can i also check that i m not inserting same data over and over ?

Thank you..

2 Answers 2

1

So I assume that you already have the queries to insert the data. So the question is really "Can I also check that I m not inserting the same data over and over again?".

There are a couple of ways you can do this. One simple way is to create a constraint on the columns in your table. Let's assume that they are col1,col2 and col3. So you could create a unique constraint on the table like this:

ALTER TABLE table_name 
ADD CONSTRAINT Constraint_Name unique(col1,col2,col3) 

A composite primary key will also achieve this, but you may already be using the primary key in a different column.

0

What is the need to have two servers with the same database and the same information? The Two databases receive data from system?

It would not be the case that you look at the SQL Server Replication?

https://msdn.microsoft.com/en-us/library/ms151198(v=sql.105).aspx

If it don't fit try implement a trigger that do it for you.

2
  • The data comes from the application and for some reason if i put the trigger it doesnt let the data come to the server from the application . There are two servers because of security concern...
    – Krish
    Jul 24, 2015 at 18:09
  • 1
    Try SQL Server Replication.
    – Krismorte
    Jul 24, 2015 at 21:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.