SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 BCP steps
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

abc123
Starting Member

47 Posts

Posted - 02/11/2009 :  06:14:32  Show Profile  Reply with Quote
Hi,
Please tell me the steps for BCP in and out

abc123
Starting Member

47 Posts

Posted - 02/11/2009 :  06:15:21  Show Profile  Reply with Quote
I have SQL server 2005 installed
Go to Top of Page

sakets_2000
Flowing Fount of Yak Knowledge

India
1472 Posts

Posted - 02/11/2009 :  06:58:47  Show Profile  Reply with Quote
have a look at books online. This is a nice article as well.
http://www.sqlteam.com/article/exporting-data-programatically-with-bcp-and-xp_cmdshell
Go to Top of Page

abc123
Starting Member

47 Posts

Posted - 02/11/2009 :  07:22:25  Show Profile  Reply with Quote
i have tried but getting following error

C:\Documents and Settings\187593>bcp 'SELECT * FROM SBx..CreditScore' queryout CreditScore.txt -U lm -P lm -c
'bcp' is not recognized as an internal or external command,
operable program or batch file.
Go to Top of Page

Rajesh Jonnalagadda
Starting Member

India
45 Posts

Posted - 02/11/2009 :  07:31:29  Show Profile  Visit Rajesh Jonnalagadda's Homepage  Reply with Quote
Try this,
DECLARE @FileName NVARCHAR(100)
,@bcpCommand NVARCHAR(1000)
,@FilePath NVARCHAR(100)

SET @bcpCommand = 'bcp "SELECT * FROM DatabaseName.dbo.TableName" queryout "'
SET @bcpCommand = @bcpCommand + @FilePath+ @FileName + '" -c -T -t","'

EXEC master..xp_cmdshell @bcpCommand

Rajesh Jonnalagadda
GGK TECH
Go to Top of Page

sakets_2000
Flowing Fount of Yak Knowledge

India
1472 Posts

Posted - 02/11/2009 :  07:38:03  Show Profile  Reply with Quote
quote:
Originally posted by abc123

i have tried but getting following error

C:\Documents and Settings\187593>bcp 'SELECT * FROM SBx..CreditScore' queryout CreditScore.txt -U lm -P lm -c
'bcp' is not recognized as an internal or external command,
operable program or batch file.



Are you running from command prompt ? You sure you have MS client installed on the machine ? The links I gave you describe how to run it from the analyzer.
Go to Top of Page

abc123
Starting Member

47 Posts

Posted - 02/11/2009 :  07:41:28  Show Profile  Reply with Quote
i have tried as

C:\Program Files\Microsoft SQL Server\90\Tools\Binn>bcp 'SELECT * FROM SBx..Cred
itScore' queryout CreditScore.txt -U lm -P lm -c
'bcp' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files\Microsoft SQL Server\90\Tools\Binn>
Go to Top of Page

sakets_2000
Flowing Fount of Yak Knowledge

India
1472 Posts

Posted - 02/11/2009 :  07:49:28  Show Profile  Reply with Quote
do you have bcp.exe @ C:\Program Files\Microsoft SQL Server\90\Tools\Binn ??? check in the machine from where you are running it.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.19 seconds. Powered By: Snitz Forums 2000