Showing posts with label replicate. Show all posts
Showing posts with label replicate. Show all posts

Friday, March 30, 2012

How to create second publisher record on the server?

Hello...
What we are trying to accomplish is to be able to replicate from Sql Server 2000 to some laptops running MSDE across the internet. These laptops are NOT part of our domain. I have set up a publication to allow for anonymous pull subscriptions for transa
ctional replication. Everything works fine now...except that for my test I had to setup/configure the laptop with a Hosts and LMHosts file so that it could resolve the server's name from its fully qualified name. This will be a pain for us to implement
and deploy....as we will have hundreds of client machines connecting to our server. The problem has to do with a sql server table that stores the name of the server publisher & distributor.
I noticed (via the sql server profiler tool) that when replication begins, there is some intial login/handshaking that occurs and one of the principal commands that gets executed is something like: exec sp_helpdistpublisher N'ServerName'. This stored pr
oc queries the MSDistPublisher table in the MSDB database. The stored proc returns a single row of data which includes our server's name...as it has been setup...it's machine name. This table does not include (obviously) a record that has the server's fu
lly qualified domain name (ServerName.Domain.Com).
My question is: is there a way to add an additional row of data and use the fully qualified domain name?
thanks for any help.
- DW
in your application, can't you hard code the publisher name with the FQDN
for the publisher/distributor?
Hilary Cotter
Looking for a book on SQL Server replication?
http://www.nwsu.com/0974973602.html
"DW" <DW@.discussions.microsoft.com> wrote in message
news:62391DE0-137B-46EE-9024-9E679829FD84@.microsoft.com...
> Hello...
> What we are trying to accomplish is to be able to replicate from Sql
Server 2000 to some laptops running MSDE across the internet. These laptops
are NOT part of our domain. I have set up a publication to allow for
anonymous pull subscriptions for transactional replication. Everything
works fine now...except that for my test I had to setup/configure the laptop
with a Hosts and LMHosts file so that it could resolve the server's name
from its fully qualified name. This will be a pain for us to implement and
deploy....as we will have hundreds of client machines connecting to our
server. The problem has to do with a sql server table that stores the name
of the server publisher & distributor.
> I noticed (via the sql server profiler tool) that when replication begins,
there is some intial login/handshaking that occurs and one of the principal
commands that gets executed is something like: exec sp_helpdistpublisher
N'ServerName'. This stored proc queries the MSDistPublisher table in the
MSDB database. The stored proc returns a single row of data which includes
our server's name...as it has been setup...it's machine name. This table
does not include (obviously) a record that has the server's fully qualified
domain name (ServerName.Domain.Com).
> My question is: is there a way to add an additional row of data and use
the fully qualified domain name?
> thanks for any help.
> - DW

Wednesday, March 7, 2012

How to count existing items?

I want to check and see if an item exists within one of my tables
before I go and replicate. let's say that "John Doe" already exists in
a names database and the user tries to add him again, i want to notify
the user that this name already exists. also, i want to do this
programatically(sp?) in C#.
any help?Put a unique constraint on the identifying columns. When you try to
insert (using a stored procedure), SQL Server will throw an error
(2627). Handle the error in your C# app.
JLuv wrote:
> I want to check and see if an item exists within one of my tables
> before I go and replicate. let's say that "John Doe" already exists in
> a names database and the user tries to add him again, i want to notify
> the user that this name already exists. also, i want to do this
> programatically(sp?) in C#.
> any help?|||You could do this in this manner
USE Northwind
GO
IF NOT EXISTS
( SELECT (LastName)
FROM Employees
WHERE ( LastName = 'Fuller'
AND FirstName = 'Andrea'
)
) INSERT INTO Employees
( LastName
, FirstName
)
VALUES
( 'Fuller'
, 'Andrea'
)
Your application can check the RowCount (RowsAffected) to determine if more
0 (zero) rows were inserted. Then message the user appropriately.
--
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"JLuv" <JLuv3k6@.gmail.com> wrote in message news:1151692692.332535.294860@.75g2000cwc.google
groups.com...
>I want to check and see if an item exists within one of my tables
> before I go and replicate. let's say that "John Doe" already exists in
> a names database and the user tries to add him again, i want to notify
> the user that this name already exists. also, i want to do this
> programatically(sp?) in C#.
> any help?
>|||i've never tried that before. is this method called a "unique
constraint"? what should i search for to find information on this?
Stu wrote:
> Put a unique constraint on the identifying columns. When you try to
> insert (using a stored procedure), SQL Server will throw an error
> (2627). Handle the error in your C# app.
>
> JLuv wrote:|||i did something like that. i went and updated the database with the
exact same information it already holds. it returns the correct # of
columns affected using ExecuteNonQuery().
Arnie Rowland wrote:
> You could do this in this manner
> USE Northwind
> GO
> IF NOT EXISTS
> ( SELECT (LastName)
> FROM Employees
> WHERE ( LastName = 'Fuller'
> AND FirstName = 'Andrea'
> )
> ) INSERT INTO Employees
> ( LastName
> , FirstName
> )
> VALUES
> ( 'Fuller'
> , 'Andrea'
> )
> Your application can check the RowCount (RowsAffected) to determine if mor
e 0 (zero) rows were inserted. Then message the user appropriately.
>
> --
> Arnie Rowland, YACE*
> "To be successful, your heart must accompany your knowledge."
> *Yet Another certification Exam
>
> "JLuv" <JLuv3k6@.gmail.com> wrote in message news:1151692692.332535.294860@.
75g2000cwc.googlegroups.com...|||You could also use the 'Primary Key' -it is by design a 'unique constraint'.
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"JLuv" <JLuv3k6@.gmail.com> wrote in message
news:1151694549.094788.110810@.h44g2000cwa.googlegroups.com...
> i've never tried that before. is this method called a "unique
> constraint"? what should i search for to find information on this?
>
> Stu wrote:
>|||Not columns affected -BUT Rows Affected. Notice the use of IF NOT EXISTS.
That prevents adding a row that meets the WHERE clause criteria.
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"JLuv" <JLuv3k6@.gmail.com> wrote in message
news:1151694709.234122.133440@.75g2000cwc.googlegroups.com...
>i did something like that. i went and updated the database with the
> exact same information it already holds. it returns the correct # of
> columns affected using ExecuteNonQuery().
>
> Arnie Rowland wrote:
>|||yea, i mean row, not column. and i'll try out IF NOT EXIST
Arnie Rowland wrote:
> Not columns affected -BUT Rows Affected. Notice the use of IF NOT EXISTS.
> That prevents adding a row that meets the WHERE clause criteria.
> --
> Arnie Rowland, YACE*
> "To be successful, your heart must accompany your knowledge."
> *Yet Another certification Exam
>
> "JLuv" <JLuv3k6@.gmail.com> wrote in message
> news:1151694709.234122.133440@.75g2000cwc.googlegroups.com...|||The only real reason to use this 'IF NOT EXISTS' form is if you wish to have
an ELSE -such as update an existing record.
Otherwise, just insert the data and let the unique constraint or Primary key
force an error and your application can capture the error and react
accordingly.
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"JLuv" <JLuv3k6@.gmail.com> wrote in message
news:1151695591.304350.187130@.i40g2000cwc.googlegroups.com...
> yea, i mean row, not column. and i'll try out IF NOT EXIST
>
> Arnie Rowland wrote:
>