If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Sql server database synch b

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-28-12, 09:49
pras123 pras123 is offline
Registered User
 
Join Date: Mar 2012
Posts: 1
Sql server database synch b

Hi,

I have created a dotnet windows application (dotnet 3.5, visual studio 2008 editor) and sql server 2008 database as backend.

Whenever network is available my application connects to server database
and when network is not available then application connects to local database.


But next time when application is opened then data and also schema should be synchronized between local database and server database.

So please tell me how to do this.

Also primary key columns are set as auto increment in each table.

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-28-12, 13:16
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
AND the schema?

Doesn't this just sound like a very bad idea to you?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #3 (permalink)  
Old 03-28-12, 14:40
Mikefox1207 Mikefox1207 is offline
Registered User
 
Join Date: Mar 2012
Location: Somewhere In Europe
Posts: 19
Hi Pras

You can use database replication to sync databases, but there can occur data conflicts. I have to agree with Brett, it's not good idea.

Regards
Mike
Reply With Quote
  #4 (permalink)  
Old 03-28-12, 15:39
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 12,327
Specifically you'll want to use Merge Replication.
I don't know how it will handle the out-of-sync identity key values.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
www.LobsterShot.blogspot.com
Reply With Quote
  #5 (permalink)  
Old 03-28-12, 15:48
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
Quote:
Originally Posted by Mikefox1207 View Post
I have to agree with Brett

Regards
Mike

And as OFTEN as that happens...it never gets old

__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #6 (permalink)  
Old 03-28-12, 16:54
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,292
Quote:
Also primary key columns are set as auto increment in each table.
You should change the data type of the PK's to GUIDs.
__________________
With kind regards . . . . . SQL Server 2000/2005/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #7 (permalink)  
Old 03-28-12, 17:21
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
Quote:
Originally Posted by Wim View Post
You should change the data type of the PK's to GUIDs.
God Forbid
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #8 (permalink)  
Old 03-28-12, 19:44
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,292
Quote:
God Forbid
Why? It's the only case I'd ever use GUIDs.
__________________
With kind regards . . . . . SQL Server 2000/2005/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #9 (permalink)  
Old 03-29-12, 09:05
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 12,327
Quote:
Originally Posted by Brett Kaiser View Post
Quote:
Originally Posted by Wim View Post
You should change the data type of the PK's to GUIDs.
God Forbid
For merging datasets? GUIDs are the best solution.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
www.LobsterShot.blogspot.com
Reply With Quote
  #10 (permalink)  
Old 03-29-12, 10:55
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
Your better of Architecting a better solution
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #11 (permalink)  
Old 03-29-12, 16:02
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 13,562
Heavens to murgatroid. I use GUID values and UTC dates/times for any database that requires merge replication. Anything else would beat me bloody!

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #12 (permalink)  
Old 03-29-12, 16:28
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
Any problems with Duplicates?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #13 (permalink)  
Old 03-29-12, 17:04
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 13,562
Quote:
Originally Posted by Brett Kaiser View Post
Any problems with Duplicates?
Using carefully contrived lab procedures I can sometimes generate duplicate GUID values. There are a couple of ways that I can do it repeatably, but I can't imagine those happening in the real world.

Because the GUID is a fixed size, it is guaranteed to have duplicates occur naturally in due time... The most conservative estimate I've seen for an expected collision is over 1800 years, and most estimates are in the tens of millions or more years. Even at 1800 years I don't expect any code I write or even the data associated with that code to be around anymore, and if it is around then I'm pretty comfortable that someone will have a convenient way to deal with the problem by then!

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On