Tuesday, March 20, 2012

Script replication

I have configured transactional replication between two sql servers 2000 by
wizard, i have one publisher and one subscriber (distributor is on same
server as publisher)
I need to script all part of replication but for installing later and when i
try it it's not successed.
Can somebody provide me what really i need to script on punlisher on
subscriber .... ...... ...
Also if on istallation the servers name will be differen from those that i
did script.
Thanks
Message posted via http://www.droptable.com
The easiest thing to do is to get Enterprise manager to generate the script
for you. One thing I've started doing is running some sqldmo each evening to
produce such textfiles automatically. This way I can be sure to have a
backed up version of my replication settings:
Dim objDMO As SQLServer
Dim objReplication As Replication2
Dim fso As FileSystemObject
Dim ts As TextStream
Dim sFilename As String
Set objDMO = New SQLDMO.SQLServer
Set fso = New FileSystemObject
sDirectoryPath = "c:\"
objDMO.LoginSecure = True
objDMO.Connect "crazyfrog"
Set objReplication = objDMO.Replication
sFilename = sDirectoryPath & objDMO.Name & CStr(Year(Now())) &
CStr(Month(Now())) & CStr(Day(Now())) & ".txt"
Set ts = fso.OpenTextFile(sFilename, ForWriting, True)
ts.Write objReplication.Script(SQLDMORepScript_InstallDistr ibutor Or
SQLDMORepScript_InstallPublisher)
ts.Close
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Thanks Paul, however i got problem with this script, first of all where i
should run this script via DTS?
Please can u explain me in more detail how to use this script
TNX
Message posted via http://www.droptable.com
|||You'd be best running this in a programming environment like VB or VB.NET.
You could also run it in an activex script task, but then you'll have to use
a non object-oriented environment and use variants instead. If you just need
a one-off, then EM is the easiest way to go.
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||OK, thanks.
iwould like to perform it via DTS, if i only remove all classes name on
variables define it's not help, can u advice me something,
TNX
Message posted via http://www.droptable.com
|||here you go...
'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************
Function Main()
Dim objDMO
Dim objReplication
Dim fso
Dim tf
Set objDMO = CreateObject("SQLDMO.SQLServer")
Set fso = CreateObject("Scripting.FileSystemObject")
objDMO.LoginSecure = True
objDMO.Connect "crazyfrog"
Set objReplication = objDMO.Replication
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("c:\testfile.txt", True)
tf.Write objReplication.Script(1048576)
tf.Close
Main = DTSTaskExecResult_Success
End Function
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Thanks very usefull, i tried it works perfect.
Message posted via http://www.droptable.com
|||how to perform the script above only for specified publication, e.g. i have
few publishers on one sql server
TNX
Message posted via http://www.droptable.com
|||Have a look here: http://www.replicationanswers.com/script6.asp
You'll have to edit the text in the same way I did to make it use variants.
Rgds,
Paul Ibison, SQL Server MVP
"akej via droptable.com" <forum@.droptable.com> wrote in message
news:5086609F212F0@.droptable.com...
> how to perform the script above only for specified publication, e.g. i
> have
> few publishers on one sql server
> TNX
> --
> Message posted via http://www.droptable.com
|||Thanks in advance
Message posted via http://www.droptable.com

No comments:

Post a Comment