Avatar of marrowyung
marrowyung
 asked on

SQL server 2014 replication error

hi,

right now configuration some test on SQL server 2014 transaction replication and we receive the following error:

Error messages:

Error messages:
•	The process could not bulk copy into table '"dbo"."<tableName>"'. (Source: MSSQL_REPL, Error number: MSSQL_REPL20037)
Get help: http://help/MSSQL_REPL20037
•	Batch send failed
•	OLE DB provider 'STREAM' for linked server '(null)' returned invalid data for column '[!BulkInsert].Remark'. (Source: MSSQLServer, Error number: 7339)
Get help: http://help/7339
•	To obtain an error file with details on the errors encountered when initializing the subscribing table, execute the bcp command that appears below.  Consult the BOL for more information on the bcp utility and its supported options. (Source: MSSQLServer, Error number: 20253)
Get help: http://help/20253
bcp "FLHAECO"."dbo"."<tableName>" in "\\HXDECOUATDBS01\WorkingDir\unc\HXDECOUATDBS01_HXDB_HMS_WMS\20170314093312\<tableName>_11#27.bcp" -e "errorfile" -t"\n<x$3>\n" -r"\n<,@g>\n" -m10000 -SHXTWMSUATDB -T -w (Source: MSSQLServer, Error number: 20253)
Get help: http://help/20253

Open in new window

'

it seems that the mentioned error was due to the collation difference in source and destination DB and continuously happen in production environment as well.

I knew the diff in collation can't be solve and it involve reinstall of the DB server, right?

Are there any methods ton bypassing the those columns with different collation in replication ?
Microsoft SQL Server

Avatar of undefined
Last Comment
marrowyung

8/22/2022 - Mon
SOLUTION
Máté Farkas

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Zberteoc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
"You will have to at least change the destination database to the same collation."

but this one involve reinstall of the DB server, right?

"You can't have replication between databases with different collations"

someone discussed about the by pass option by using with ‘copy collation = True', right?

so if the target DB ran for a long time really has diff collation, what should we do other than reinstall it?

and if target DB is in diff country, language can be diff and it is normal. anyway to handle this kind of mis match ?
Vitor Montalvão

I knew the diff in collation can't be solve and it involve reinstall of the DB server, right?
Depends. If this is only intended to be for a single column or a table you can easily change the collation for the object so not necessary to reinstall the SQL Server instance.
marrowyung

ASKER
"you can easily change the collation for the object "

now we are going to change the schema of that target table and see if it works.

"you can easily change the collation for the object "

that one is a table, how to change the collation ?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
SOLUTION
Vitor Montalvão

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
ok, tks. the subscriber's table with replication turned on, it has to be disabled the replication first ?

your script just changed the collation of one columns only and it don't impact the rest  ?
Vitor Montalvão

the subscriber's table with replication turned on, it has to be disabled the replication first ?
You may need to stop the replication so you can perform the collation change.

your script just changed the collation of one columns only and it don't impact the rest  ?
Correct. It only changes that single column collation.
marrowyung

ASKER
hi,

"Correct. It only changes that single column collation."

one thing, how can I detect such a change if no documentation is made.... any script for me to detect all column's collation for any exception?  is it possible ?

I am thinking about this can make the next DBA in trouble !
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Vitor Montalvão

one thing, how can I detect such a change if no documentation is made.... any script for me to detect all column's collation for any exception?  is it possible ?
What do you mean? Do you want to track all collation changes that has been made? Only way is to create a DDL trigger and store the information somewhere so you can analyze it later.
marrowyung

ASKER
"Do you want to track all collation changes that has been made?"
e.g. which column has diff collation and then we will find out why .
Vitor Montalvão

which column has diff collation and then we will find out why .
Diff collation from what? From the other columns? table? database? instance? Or just when the collation of the column changes? If this latest then use a trigger as I've mentioned earlier.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
marrowyung

ASKER
"Diff collation from what? From the other columns?"

diff from other columns . e.g. if we just change collation of one column, by someone, we should be able to detect it out and see who did that and why .
Vitor Montalvão

Like I said before, only if you have a DDL trigger to capture all changes performed in objects.
marrowyung

ASKER
yes, totally understand.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
tks all for that, I might come back next monday as we tried to change the schema of that target table but it seems don't work,
marrowyung

ASKER
hi all,

we tried to recreate the table schema with the same definition, but diff errors comes:

Error messages:
The process could not bulk copy into table '"dbo"."HMS_ClassNomination"'. (Source: MSSQLServer, Error number: 20037)
Get help: http://help/20037
Batch send failed
OLE DB provider 'STREAM' for linked server '(null)' returned invalid data for column '[!BulkInsert].Remark'. (Source: MSSQLServer, Error number: 7339)
Get help: http://help/7339
To obtain an error file with details on the errors encountered when initializing the subscribing table, execute the bcp command that appears below.  Consult the BOL for more information on the bcp utility and its supported options. (Source: MSSQLServer, Error number: 20253)
Get help: http://help/20253
bcp "FLHAECO"."dbo"."HMS_ClassNomination" in "\\<DB server>\WorkingDir\unc\<DB server>_HXDB_TESTING\20170323155940\HMS_ClassNomination_2#27.bcp" -e "errorfile" -t"\n<x$3>\n" -r"\n<,@g>\n" -m10000 -SHXTWMSUATDB -T -w (Source: MSSQLServer, Error number: 20253)
Get help: http://help/20253

Open in new window

Vitor Montalvão

Better to you to open a new question since you'll attract more Experts.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
marrowyung

ASKER
but already answering here, right ?
Vitor Montalvão

Did you run the suggested command?
bcp "FLHAECO"."dbo"."HMS_ClassNomination" in "\\<DB server>\WorkingDir\unc\<DB server>_HXDB_TESTING\20170323155940\HMS_ClassNomination_2#27.bcp" -e "errorfile" -t"\n<x$3>\n" -r"\n<,@g>\n" -m10000 -SHXTWMSUATDB -T -w

Open in new window

Then check the errorfile.
marrowyung

ASKER
hi,

right now I found out other problems.

1) if publisher and distributor is SQL2014 and subscriber still in SQL2012, will it works ?
2) when i test using one table, when I setup a simple transaction replication, it give me this alert and replication can't continue:

error
3) I can't see why if, I found some existing replication has snapshot folder not accessible:

distributor trouble
then can't setup transaction replication at all as no folder to store the snapshot?

it seems from create replication wizard I can't see where to set to store snapshot, how can i set it?

4) is this means the distributor can be create/enable/disable in anytime, it is just a feature can be on/off ?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
hi Victor,


"Did you run the suggested command?"

it has error as it said:

" The system cannot find the file specified"

so that path :\\<DB server>\WorkingDir\unc\<DB server>_HXDB_TESTING\20170323155940\ is supposed to be snapshot files and now by some reason some process remove it, so this command doesn't works anyway.

where can I set the snapshot path of transaction replication.
Vitor Montalvão

where can I set the snapshot path of transaction replication.
Check in the Replication properties.
marrowyung

ASKER
hi,

how about this:

4) is this means the distributor can be create/enable/disable in anytime, it is just a feature can be on/off ?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
marrowyung

ASKER
I am checking this one:

"https://blogs.msdn.microsoft.com/repltalk/2015/03/04/repltip-only-one-log-reader-can-connect-message-when-dropping-a-publication/"

Sometimes when you try to drop a Transactional Publication using the GUI, you get the following error:
Only one Log Reader Agent or log–related procedure (sp_repldone, sp_replcmds, and sp_replshowcmds) can connect to a database at a time. If you executed a log–related procedure, drop the connection over which the procedure was executed or execute sp_replflush over that connection before starting the Log Reader Agent or executing another log–related procedure.

but I can't see I can see this option:

"r by right-clicking the Publication, select "View Log Reader Agent Status", then "Stop","

how come ?

I have removed all test publication from Replication-> local publications already, nothing there.
marrowyung

ASKER
Victor:

"ALTER TABLE tablename
    ALTER COLUMN columnname NVARCHAR(100) COLLATE newcollationname"

from server level I see both publisher, distributor and subscriber has the same collation. but it seems doesn't work.

I am not sure if replication replicating data from higher version (SQL2014) to lower version (SQL2012) is supported.
Vitor Montalvão

I've missed your big comment with images.
1) if publisher and distributor is SQL2014 and subscriber still in SQL2012, will it works ?
Yes, it should work.

2) when i test using one table, when I setup a simple transaction replication, it give me this alert and replication can't continue:
Looks like you have a big mess there. I'm not sure if I can help without having access to your system.

then can't setup transaction replication at all as no folder to store the snapshot?
Any Replication needs a snapshot to begin replication so yes, is a mandatory configuration.

4) is this means the distributor can be create/enable/disable in anytime, it is just a feature can be on/off ?
If you stop the distributor agent you'll stop the Replication.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Vitor Montalvão

I have removed all test publication from Replication-> local publications already, nothing there.
How did you remove it? I guess something stayed and it's originating all this mess. Check the SQL Agent jobs and verify if there's any from Replication running.
It's also a good practice to script your Replication so you can rebuild it later, easily.
marrowyung

ASKER
":How did you remove it? I guess something stayed and it's originating all this mess. Check the SQL Agent jobs and verify if there's any from Replication running."

other stuff removing by right click on it and delete. it is a UAT platform.

"If you stop the distributor agent you'll stop the Replication."

I can find it from windows service ?
Vitor Montalvão

other stuff removing by right click on it and delete.
It might be not enough. Once again, you can always generate a delete script for later use.

I can find it from windows service ?
No. Isn't a service but a SQL Agent job but you should interact with it by using the Replication Monitor.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
marrowyung

ASKER
"No. Isn't a service but a SQL Agent job but you should interact with it by using the Replication Monitor.

sorry, this is the turn distributor on and off?
Vitor Montalvão

sorry, this is the turn distributor on and off?
Yes but I wouldn't do that unless you need to perform some maintenance task.
marrowyung

ASKER
"Yes but I wouldn't do that unless you need to perform some maintenance task.

sorry, what ?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Vitor Montalvão

turn distributor on and off
marrowyung

ASKER
ok. I will double check next week.

tomorrow will update AOG ticket. :):)