Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

BCP Error On New Server Expand / Collapse
Author
Message
Posted Wednesday, September 19, 2012 9:03 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:08 PM
Points: 20,905, Visits: 32,960
Okay, don't know how many ways I can say it. It looks like you need to add the -S parameter to your BCP command line. Without it BCP is trying to connect to the default instance of SQL Server and you have specified that you are using a named instance on the new server. This means you need to tell bcp the name of the instance.

This:


SELECT @sMysql = 'bcp "SELECT sOutput FROM MYDATABASE.dbo.VPOSITIVEPAY" queryout ' + @sFilePath + @sFileName + ' -S [SQLSVR04\SS2005] -T -c'


Notice the -S parameter I have added.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1361417
Posted Wednesday, September 19, 2012 9:38 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, December 22, 2014 2:12 PM
Points: 893, Visits: 1,563
Lynn Pettis (9/19/2012)
Okay, don't know how many ways I can say it. It looks like you need to add the -S parameter to your BCP command line. Without it BCP is trying to connect to the default instance of SQL Server and you have specified that you are using a named instance on the new server. This means you need to tell bcp the name of the instance.

This:


SELECT @sMysql = 'bcp "SELECT sOutput FROM MYDATABASE.dbo.VPOSITIVEPAY" queryout ' + @sFilePath + @sFileName + ' -S [SQLSVR04\SS2005] -T -c'


Notice the -S parameter I have added.



Lynn,

I did not see the -s param n any of the previous posts. It wasn't until this last post when the comments pointed to something not being seen that I realized there was more text then what I was seeing. My browser was only showing up thru to the '+@sFileName' piece and I did not reliaze there was anything more/diferfent after. If I had I certainly would not have continued to post lengthy messages and do tests when there was something to try that I had not done. Thank you.


That said, it still failed and I copied your sample code just to make sure I did not miss anything or cotain any typos. And I did try it like this:

SELECT @sMysql = 'bcp "SELECT sOutput FROM MYDATABASE.dbo.VPOSITIVEPAY" queryout ' + @sFilePath + @sFileName + ' -S [SQLSVR04\SS2005] -T -c'


And like this just in case it made a difference:

SELECT @sMysql = 'bcp "SELECT sOutput FROM [SQLSVR04\SS2005].MYDATABASE.dbo.VPOSITIVEPAY" queryout ' + @sFilePath + @sFileName + ' -S [SQLSVR04\SS2005] -T -c'


What is DIFFERENT using the -S param is that the query fails when run from the old server and the new server. This is the first test where it failed when run from the old server.

Thanks


Kindest Regards,

Just say No to Facebook!
Post #1361445
Posted Wednesday, September 19, 2012 9:43 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:08 PM
Points: 20,905, Visits: 32,960
On the new server, what was the error message? (Sorry, but saying it failed doesn't tell us anything.)



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1361452
Posted Wednesday, September 19, 2012 9:53 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:08 PM
Points: 20,905, Visits: 32,960
The following worked on my laptop system which uses a named instance for SQL Server 2005:


bcp "select * from master.sys.databases" queryout C:\Users\lynn.pettis\testfile.txt -S ISS203897\ISS2K5 -T -c


The following failed on my laptop system which uses a named instance for SQL Server 2005:


bcp "select * from master.sys.databases" queryout C:\Users\lynn.pettis\testfile.txt -T -c



So, with that, try this:


SELECT @sMysql = 'bcp "SELECT sOutput FROM MYDATABASE.dbo.VPOSITIVEPAY" queryout ' + @sFilePath + @sFileName + ' -S SQLSVR04\SS2005 -T -c'





Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1361462
Posted Wednesday, September 19, 2012 4:11 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:08 PM
Points: 20,905, Visits: 32,960
Bump. Have you tried my latest change? You know, not including the [ ] around the server name and instance name with the -S parameter to bcp?


Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1361680
Posted Thursday, September 20, 2012 12:09 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, December 22, 2014 2:12 PM
Points: 893, Visits: 1,563
Lynn Pettis (9/19/2012)
Bump. Have you tried my latest change? You know, not including the [ ] around the server name and instance name with the -S parameter to bcp?


Lynn,

I'm just now getting back to working on this. I just tried your last suggestion and that one DID work. While I'm gald to get this working I am curious as to what it is about the new server that reuires this kind of change. Is it just because its a named instance?


Kindest Regards,

Just say No to Facebook!
Post #1362216
Posted Thursday, September 20, 2012 12:14 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:08 PM
Points: 20,905, Visits: 32,960
YSLGuru (9/20/2012)
Lynn Pettis (9/19/2012)
Bump. Have you tried my latest change? You know, not including the [ ] around the server name and instance name with the -S parameter to bcp?


Lynn,

I'm just now getting back to working on this. I just tried your last suggestion and that one DID work. While I'm gald to get this working I am curious as to what it is about the new server that reuires this kind of change. Is it just because its a named instance?


Yes, as I believe I mentioned a few posts back. When you don't include the -S parameter BCP attempts to connect to the default instance of SQL Server on the server that it is being run on. This is why it would run on the old server. You were probably able to access the data on the new server, and this is a guess on my part, because you probably have a linked server defined on the old server pointing to the new server. When you added the -S parameter, the problem then was we kept the square brackets around the servername\instancename and bcp didn't like it. That's when I played with bcp on my laptop and found that those needed to go bye bye.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1362219
Posted Monday, September 24, 2012 9:06 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, December 22, 2014 2:12 PM
Points: 893, Visits: 1,563
Lynn Pettis (9/20/2012)
YSLGuru (9/20/2012)
Lynn Pettis (9/19/2012)
Bump. Have you tried my latest change? You know, not including the [ ] around the server name and instance name with the -S parameter to bcp?


Lynn,

I'm just now getting back to working on this. I just tried your last suggestion and that one DID work. While I'm gald to get this working I am curious as to what it is about the new server that reuires this kind of change. Is it just because its a named instance?


Yes, as I believe I mentioned a few posts back. When you don't include the -S parameter BCP attempts to connect to the default instance of SQL Server on the server that it is being run on. This is why it would run on the old server. You were probably able to access the data on the new server, and this is a guess on my part, because you probably have a linked server defined on the old server pointing to the new server. When you added the -S parameter, the problem then was we kept the square brackets around the servername\instancename and bcp didn't like it. That's when I played with bcp on my laptop and found that those needed to go bye bye.



Lynn,

Corret me if I'm wrong but with the exception of this BCP specific case, aren't the use of the brackets always required when using a name that includes the slash for a namaed instance?

thanks


Kindest Regards,

Just say No to Facebook!
Post #1363558
Posted Monday, September 24, 2012 11:06 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:08 PM
Points: 20,905, Visits: 32,960
YSLGuru (9/24/2012)
Lynn Pettis (9/20/2012)
YSLGuru (9/20/2012)
Lynn Pettis (9/19/2012)
Bump. Have you tried my latest change? You know, not including the [ ] around the server name and instance name with the -S parameter to bcp?


Lynn,

I'm just now getting back to working on this. I just tried your last suggestion and that one DID work. While I'm gald to get this working I am curious as to what it is about the new server that reuires this kind of change. Is it just because its a named instance?


Yes, as I believe I mentioned a few posts back. When you don't include the -S parameter BCP attempts to connect to the default instance of SQL Server on the server that it is being run on. This is why it would run on the old server. You were probably able to access the data on the new server, and this is a guess on my part, because you probably have a linked server defined on the old server pointing to the new server. When you added the -S parameter, the problem then was we kept the square brackets around the servername\instancename and bcp didn't like it. That's when I played with bcp on my laptop and found that those needed to go bye bye.



Lynn,

Corret me if I'm wrong but with the exception of this BCP specific case, aren't the use of the brackets always required when using a name that includes the slash for a namaed instance?

thanks


I think you only need them when using 4-part naming convention when specifying tables/views in a FROM clause. You use them due to the \ in the name. I think you would leave them off when specifying the server in a SQLCMD command line as well.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1363636
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse