May 15, 2013 at 7:57 am
hi there, hope in your help.
I tried this code in sql server, but I've this error.
Can you help me?
I would really appreciate any help.
sp_configure 'Allow Updates',
0;
RECONFIGURE WITH override;
EXEC master.dbo.sp_configure 'show advanced options',
1 RECONFIGURE EXEC master.dbo.sp_configure 'xp_cmdshell',
1 RECONFIGURE EXEC xp_cmdshell 'bcp "SELECT * FROM [dbo].[tbl];" queryout "\\XX.XX.XX.XX\output.txt" -T -c -t;'
SQLState = 08001, NativeError = 2
Error = [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [2].
SQLState = 08001, NativeError = 2
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 config
ured 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
May 15, 2013 at 2:42 pm
cms9651 (5/15/2013)
hi there, hope in your help.I tried this code in sql server, but I've this error.
Can you help me?
I would really appreciate any help.
sp_configure 'Allow Updates',
0;
RECONFIGURE WITH override;
EXEC master.dbo.sp_configure 'show advanced options',
1 RECONFIGURE EXEC master.dbo.sp_configure 'xp_cmdshell',
1 RECONFIGURE EXEC xp_cmdshell 'bcp "SELECT * FROM [dbo].[tbl];" queryout "\\XX.XX.XX.XX\output.txt" -T -c -t;'
SQLState = 08001, NativeError = 2
Error = [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [2].
SQLState = 08001, NativeError = 2
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 config
ured 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
A few things:
1. 'Allow Updates' has not done anything since SQL 2005 was released so you can drop that from your script. Reference
2. Do not use RECONFIGURE WITH OVERRIDE; unless you have a good reason. I know SSMS spits it out when you script a change done through the GUI, but I would recommend against ever executing it in a script.
3. Are you sure you want to use xp_cmdshell? Only use it if you have no other options, and I am confident that I can help you find a better option. At a higher level than just "I need to get data from a table into a file", what exactly are you designing?
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
May 16, 2013 at 1:13 am
thank you for help.
I need to get data from a table into a file txt.
May 16, 2013 at 6:06 am
Is this going to be an ongoing process or is it just a one-off?
May 16, 2013 at 6:11 am
This is an ongoing process, planned in the server
May 16, 2013 at 7:12 am
Are you on an Edition of SQL Server that has SQL Agent? In other words not SQL Express Edition?
If so, I would recommend you setup a SQL Agent Job to run bcp for you. When you setup the job, the Job Step Type will be "Operating System (CmdExec)" and in the command you will put your call to bcp. Then you can schedule the job to run as needed.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
May 16, 2013 at 7:25 am
opc.three (5/16/2013)
Are you on an Edition of SQL Server that has SQL Agent? In other words not SQL Express Edition?
Not Sir, the db is to remote server and I use the navicat SQL Server for connected to db
May 16, 2013 at 7:25 am
OPC has got it. An SQL Server Agent job with BCP is definately the answer.
If however you have an Express version, I would recommend creating an OS-level Batch Job that calls BCP and then running the batch using Windows Scheduler.
May 16, 2013 at 9:15 am
It's possible you are getting an error on the pathing that you don't see. The command will require that the account running SQL Server (service account) has rights to the \\xx.xx.xx.xx\xx share.
What you might try doing is double checking rights or changing to a local path for testing. Then if the bcp works, you can add the specific rights to the service account.
May 16, 2013 at 9:17 am
I'm sorry but it looks to me like that does nothing more than assign a string to a variable.
Have you looked into the previous suggestions made?
May 17, 2013 at 5:01 am
thanks so much
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply