I execute a bcp command in 2 computer. The first computer has windows xp and second one has windows server 2003. when I execute command in first, the bcp run successfully but when I run this on second one, occur this error:
Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Code page 720 is not supp
orted by SQL Server
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Unable to resolve column level collat
ions
BCP copy out failed
what is the problem?
You might take a look at the following article and play with the switches in you BCP statement.
Copying Data Between Different Collations
Related
I'm having an interesting error when I'm trying to trigger an SP on a local SQL Server with two linked servers.
The purpose of the exorcise above is to move data from one linked server to another.
When I'm triggering the stored procedure from SSMS it works like a charm, but when I trigger it from Python I'm getting these sexy error messages:
(
'42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The OLE DB provider "SQLNCLI11" for linked server "XXXX" reported an error. One or more arguments were reported invalid by the provider. (7399) (SQLExecDirectW)
; [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "XXXX" was unable to begin a distributed transaction. (7391)
; [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]OLE DB provider "SQLNCLI11" for linked server "XXXX" returned message "The parameter is incorrect.". (7412)'
)
In short my python scripts (that fails with the errors above) looks as follows:
MyConn = pyodbc.connect(DRIVER="ODBC Driver 17 for SQL Server",SERVER=os.environ["sqlServer"],UID=os.environ["sqlUID"],DATABASE=os.environ["sqlDB"],PWD=os.environ["sqlPWD"])
Cursor = MyConn.cursor()
sqlQuery = "exec dbo.usp_XXXXETL #LookBackDays = 0"
Cursor.execute(sqlConta)
I've also tested the connection above; I'm able to run select statements against the linked servers from python.
What's even more annoying is that when I write it in R it works:
conn = odbcDriverConnect("Driver={ODBC Driver 17 for SQL Server};Server=*SameServer*;Database=*SameDB*;Uid=*Uid*;Pwd=*Pwd*;Connection Timeout=360;")
sqlExecute(
conn,
query="dbo.usp_XXXXETL #LookBackDays = 0",
fetch=FALSE,
errors=TRUE,
query_timeout=300)
Obviously it works so it's no big problem, it's just that I hate R-scrips and am sort of puzzled by the error.
In advance many thanks for your time and brain power!
You've started a transaction, and the linked server is configured to enlist the remote server in the transaction, which required MSDTC. So
1) Don't start a transaction. You've probably got autocommit off, which causes the session to use implicit transactions.
2) Disable the remote proc transaction promotion option for the linked server with sp_serveroption
3) Troubleshoot MSDTC to enable the distributed transaction.
Other people have asked this question, but I didn't find an answer that specifically addresses the problem I was getting nor that solved the issue. So I'm posting the question and answer.
A few days ago I had a couple automated scripts that connect to SQL Server and export some data, suddenly stop working. They've been running fine for like 7 years, so that this was odd. Both scripts use different methods to connect. One uses a Perl library, the other uses the bcp command. But both were getting the same error. I'll just show the bcp command for brevity. This is all running on Windows Server 2008, with SQL Server 2008 R2, v10.50. This is what I was running:
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\bcp.exe" "<my query>" queryout "<output file name>" -T -S MYSERVER -c -k
This is the error I was getting:
SQLState = 08001, NativeError = 10061
Error = [Microsoft][SQL Server Native Client 10.0]TCP Provider: No connection could be made because the target machine actively refused it.
SQLState = 08001, NativeError = 10061
Error = [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Login timeout expired
The solution was pretty simple. I just added the port number to the server name (changed MYSERVER to MYSERVER,1433). So my final bcp command looked like:
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\bcp.exe" "<my query>" queryout "<output file name>" -T -S MYSERVER,1433 -c -k
I'm not sure what changed to require including the port. But that's all it took.
It's kinda weird that this isn't just the default port. You'd think bcp would use that without needing to explicitly set it. Though, this could just be some weird server configuration thing that suddenly requires the port.
Anyone know a good reason why bcp cannot connect to a sql server hosted by AWS while SSMS can?
I have double checked the server and user account details and they both match.
I'm using the generic command to import a csv file:
bcp DB_Name.dbo.Table in "somefile_file.csv" -c -S xxx.rds.amazonaws.com -U username -P xxx -b 1000
The error is:
SQLState = 08001, NativeError = 53
Error = [Microsoft][ODBC Driver 13 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53].
SQLState = 08001, NativeError = 53
Error = [Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired
Is bcp using a different port maybe?
The first error shows that bcp uses the Named Pipes protocol to connect to the server. Apparently, this protocol is inaccessible for network connections.
On the client workstation where bcp is run, check SQL Server Configuration Manager and ensure that, in the client configuration list TCP/IP is enabled and prioritised. Strangely enough, bcp doesn't have a command line switch for protocol selection, so this is the only way to manage it I can think of.
P.S. Another option is to specify the server address in the form ip_address,port_number, but I don't think you will find this option particularly attractive.
I'm struggling with bcp. If I run the following SQL
exec xp_cmdshell 'bcp "select a.displayname, a.samaccountname, a.mail, a.title, a.givenname, a.sn from web_repository.dbo.activedirectory a ORDER BY displayname" queryout "C:\phonegapdownload\test.dat" -N -S IISSERVER -T '
it works fine, however if I run this
exec xp_cmdshell 'bcp "EXEC SelectAllFromADNoJoin" queryout "C:\phonegapdownload\test.dat" -N -S IISSERVER -T '
which has the exact same SQL in it, it throws an error
SQLState = 37000, NativeError = 2812
// not sure where I got this error from
It's running on SQL Server 2008 R2
Can anyone help?
I have checked that SQL Server allows remote connections and that tcpip is enabled
SQLState = 08001, NativeError = 53
Error = [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53].
SQLState = 08001, NativeError = 53
Error = [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Login timeout expired
Posting the full text of the error message would help. Error 2812 is "Could not find stored procedure". You will want to specify the -d option to specify your database, or use a quoted name (MyDB.dbo.SelectAllFromADNoJoin).
Dear Stackoverflow Gurus,
I am having an issue connecting to MS SQL Server (2008) from PostgreSQL 9.3 on Windows. I am trying to connect through DBI-Link DBD::ODBC for Sql Server.
I would like your help on how to solve this issue, or maybe point out another way to Communicate to SQL Server from PostgreSQL on Windows.
The drivers seem to be working because when I add wrong credentials I get:
Severity: ERROR, Code: XX000, Line: 2117, Position: ErrorMessage: DBI
connect('Driver={SQL
Server};Server=10.XX.YY.ZZ\MyInstance','a_user',...) failed:
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user
'a_user'. (SQL-28000) at line 37. at line 35.
The Query I am using to create the connection (in Postgres) is:
UPDATE
pg_catalog.pg_settings
SET
setting =
CASE WHEN 'dbi_link' = ANY(string_to_array(setting, ','))
THEN setting
ELSE 'dbi_link,' || setting
END
WHERE
name = 'search_path'
;
SELECT make_accessor_functions(
'dbi:ODBC:Driver={SQL Server};Server=10.XX.YY.ZZ\MyInstance',
'a_user',
'Some_Password',
'---
AutoCommit: 1
RaiseError: 1
',
NULL,
NULL,
NULL,
'dbo'
);
The error I get (which also looks like it did connect) is:
Severity: ERROR, Code: XX000, Line: 2117, Position:
ErrorMessage: Could not connect to database
data source: dbi:ODBC:Driver={SQL Server};Server=10.XX.YY.ZZ\MyInstance
user: a_user
password: Some_Password
dbh attributes:
---
AutoCommit: 1
RaiseError: 1
[Microsoft][ODBC SQL Server Driver][SQL Server]Changed database context to 'master'. (SQL-01000)
[Microsoft][ODBC SQL Server Driver][SQL Server]Changed language setting to us_english. (SQL-01000) at line 35.
My System:
OS: Windows 7 64-bit
PostgreSQL: 9.3
Perl: Strawberry Perl 5.14.3
Python: 3.4
Thanks